diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..5cc1873034 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +generated +__fixtures__ +dist \ No newline at end of file diff --git a/test/webpack/base.test.js b/test/webpack/base.test.js new file mode 100644 index 0000000000..d783c25bb6 --- /dev/null +++ b/test/webpack/base.test.js @@ -0,0 +1,29 @@ +import createDevConfig from '@lib/webpack/dev'; +import compile from './compile'; +import loadSetup from '../loadSetup'; + +describe('webpack dev config', () => { + const timeOut = 20000; // 20 seconds + + test( + 'simple', + async () => { + console.log = jest.fn(); + const props = await loadSetup('simple'); + const config = createDevConfig(props).toConfig(); + return expect(compile(config)).resolves.toBe('Compiled successfully'); + }, + timeOut + ); + + test( + 'custom', + async () => { + console.log = jest.fn(); + const props = await loadSetup('custom'); + const config = createDevConfig(props).toConfig(); + return expect(compile(config)).resolves.toBe('Compiled successfully'); + }, + timeOut + ); +}); diff --git a/test/webpack/compile.js b/test/webpack/compile.js new file mode 100644 index 0000000000..8d2f2b9516 --- /dev/null +++ b/test/webpack/compile.js @@ -0,0 +1,12 @@ +import webpack from 'webpack'; + +export default function compile(config) { + return new Promise((resolve, reject) => { + webpack(config, (err, stats) => { + if (err || stats.hasErrors()) { + reject(new Error(`Failed to compile with errors`)); + } + resolve('Compiled successfully'); + }); + }); +} diff --git a/test/webpack/index.test.js b/test/webpack/index.test.js deleted file mode 100644 index d86142588c..0000000000 --- a/test/webpack/index.test.js +++ /dev/null @@ -1,48 +0,0 @@ -import webpack from 'webpack'; -import createDevConfig from '@lib/webpack/dev'; -import createProdConfig from '@lib/webpack/prod'; -import loadSetup from '../loadSetup'; - -// webpack compiler helper function -function compile(config) { - return new Promise((resolve, reject) => { - webpack(config, (err, stats) => { - if (err || stats.hasErrors()) { - reject(new Error(`Failed to compile with errors`)); - } - resolve('Compiled successfully'); - }); - }); -} - -describe('webpack', () => { - const timeOut = 10000; // 10 seconds - - test('dev simple', async () => { - console.log = jest.fn(); - const props = await loadSetup('simple'); - const config = createDevConfig(props).toConfig(); - return expect(compile(config)).resolves.toBe('Compiled successfully'); - }, timeOut); - - test('dev custom', async () => { - console.log = jest.fn(); - const props = await loadSetup('custom'); - const config = createDevConfig(props).toConfig(); - return expect(compile(config)).resolves.toBe('Compiled successfully'); - }, timeOut); - - test('prod simple', async () => { - console.log = jest.fn(); - const props = await loadSetup('simple'); - const config = createProdConfig(props).toConfig(); - return expect(compile(config)).resolves.toBe('Compiled successfully'); - }, timeOut); - - test('prod custom', async () => { - console.log = jest.fn(); - const props = await loadSetup('custom'); - const config = createProdConfig(props).toConfig(); - return expect(compile(config)).resolves.toBe('Compiled successfully'); - }, timeOut); -}); diff --git a/test/webpack/prod.test.js b/test/webpack/prod.test.js new file mode 100644 index 0000000000..04914b9953 --- /dev/null +++ b/test/webpack/prod.test.js @@ -0,0 +1,28 @@ +import createProdConfig from '@lib/webpack/prod'; +import compile from './compile'; +import loadSetup from '../loadSetup'; + +describe('webpack production config', () => { + const timeOut = 20000; // 20 seconds + test( + 'simple', + async () => { + console.log = jest.fn(); + const props = await loadSetup('simple'); + const config = createProdConfig(props).toConfig(); + return expect(compile(config)).resolves.toBe('Compiled successfully'); + }, + timeOut + ); + + test( + 'custom', + async () => { + console.log = jest.fn(); + const props = await loadSetup('custom'); + const config = createProdConfig(props).toConfig(); + return expect(compile(config)).resolves.toBe('Compiled successfully'); + }, + timeOut + ); +});