diff --git a/.eslintignore b/.eslintignore index dc9b2375c7..5cc1873034 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,3 @@ -generated \ No newline at end of file +generated +__fixtures__ +dist \ No newline at end of file diff --git a/package.json b/package.json index 3a04e668f0..011398767d 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,6 @@ "semver": "^5.5.0", "static-site-generator-webpack-plugin": "^3.4.1", "webpack": "^4.16.3", - "webpack-bundle-analyzer": "^2.13.1", "webpack-chain": "^4.8.0", "webpack-nicelog": "^2.2.1", "webpack-serve": "^2.0.2" diff --git a/test/loadSetup.js b/test/loadSetup.js index 2aa6995b88..d16f447c38 100644 --- a/test/loadSetup.js +++ b/test/loadSetup.js @@ -1,19 +1,19 @@ -import path from 'path'; -import load from '@lib/load'; - -// Helper methods to setup dummy/ fake projects -const loadSetup = async name => { - const simpleWebsite = path.join(__dirname, '__fixtures__', 'simple-website'); - const customWebsite = path.join(__dirname, '__fixtures__', 'custom-website'); - - switch (name) { - case 'simple': - return await load(simpleWebsite); - case 'custom': - return await load(customWebsite); - default: - return {}; - } -}; - -export default loadSetup; +import path from 'path'; +import load from '@lib/load'; + +// Helper methods to setup dummy/ fake projects +const loadSetup = async name => { + const simpleWebsite = path.join(__dirname, '__fixtures__', 'simple-website'); + const customWebsite = path.join(__dirname, '__fixtures__', 'custom-website'); + + switch (name) { + case 'simple': + return load(simpleWebsite); + case 'custom': + return load(customWebsite); + default: + return {}; + } +}; + +export default loadSetup; diff --git a/test/webpack/index.test.js b/test/webpack/index.test.js index d9fe538fe3..568e3126af 100644 --- a/test/webpack/index.test.js +++ b/test/webpack/index.test.js @@ -1,48 +1,46 @@ -import webpack from 'webpack'; -import path from 'path'; -import createBaseConfig from '@lib/webpack/base'; -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', () => { - 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'); - }); - - 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'); - }); - - 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'); - }); - - 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'); - }); -}); +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', () => { + 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'); + }); + + 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'); + }); + + 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'); + }); + + 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'); + }); +});