UNPKG

react-static

Version:

A progressive static site generator for React

43 lines (39 loc) 1.11 kB
import makeWebpackConfig from '../webpack/makeWebpackConfig' import staticConfig from '../__mocks__/config.development.mock' describe('webpack', () => { it('should return after executing plugin hooks synchronously', () => { const myWebpackConfig = makeWebpackConfig({ config: staticConfig, stage: 'prod', plugins: [ { hooks: { webpack: wpConfig => ({ ...wpConfig, mode: 'development', }), }, }, ], }) expect(myWebpackConfig.mode).toBe('development') }) it('should throw if plugin hooks execute async', () => { expect(() => makeWebpackConfig({ config: staticConfig, stage: 'prod', plugins: [ { hooks: { webpack: wpConfig => Promise.resolve({ ...wpConfig, mode: 'development' }), }, }, ], }) ).toThrow( 'Expected hook to return a value, but received promise instead. A plugin is attempting to use a sync plugin with an async function!' ) }) })