test: validate generated webpack config instead of compiling

This commit is contained in:
endiliey 2018-08-12 23:17:39 +08:00
parent 1564edae4c
commit 3eb9823105
5 changed files with 121 additions and 69 deletions

View file

@ -1,28 +1,21 @@
import createProdConfig from '@lib/webpack/prod';
import compile from './compile';
import {validate} from 'webpack';
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('simple', async () => {
console.log = jest.fn();
const props = await loadSetup('simple');
const config = createProdConfig(props).toConfig();
const errors = validate(config);
expect(errors.length).toBe(0);
});
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
);
test('custom', async () => {
console.log = jest.fn();
const props = await loadSetup('custom');
const config = createProdConfig(props).toConfig();
const errors = validate(config);
expect(errors.length).toBe(0);
});
});