1 | const webpackBase = require('./index')
|
2 |
|
3 |
|
4 | jest.mock('mini-css-extract-plugin')
|
5 |
|
6 | describe('webpack-base', () => {
|
7 | beforeEach(() => {
|
8 |
|
9 |
|
10 | process.cwd = () => '/test/cwd/path'
|
11 | })
|
12 |
|
13 | test('returns loader and plugin components', () => {
|
14 | process.env.NODE_ENV = 'development'
|
15 |
|
16 | const { loaders, plugins } = webpackBase({ paths: { context: '/test' } })
|
17 | expect({ loaders, plugins }).toMatchSnapshot()
|
18 | })
|
19 |
|
20 | test('returns expected dev configs', () => {
|
21 | process.env.NODE_ENV = 'development'
|
22 |
|
23 | const { configs } = webpackBase({ paths: { context: '/test' } })
|
24 | expect(configs).toMatchSnapshot()
|
25 | })
|
26 |
|
27 | test('returns expected prod configs', () => {
|
28 | process.env.NODE_ENV = 'production'
|
29 |
|
30 | const { configs } = webpackBase({ paths: { context: '/test' } })
|
31 | expect(configs).toMatchSnapshot()
|
32 | })
|
33 |
|
34 | test('returns expected storybook configs', () => {
|
35 | process.env.NODE_ENV = 'development'
|
36 |
|
37 | const { configs } = webpackBase({
|
38 | target: 'storybook',
|
39 | paths: { context: '/test' },
|
40 | })
|
41 | expect(configs).toMatchSnapshot()
|
42 | })
|
43 |
|
44 | test('returns expected electron dev configs', () => {
|
45 | process.env.NODE_ENV = 'development'
|
46 |
|
47 | const { configs } = webpackBase({
|
48 | target: 'electron-renderer',
|
49 | paths: { context: '/test' },
|
50 | })
|
51 | expect(configs).toMatchSnapshot()
|
52 | })
|
53 |
|
54 | test('returns expected electron prod configs', () => {
|
55 | process.env.NODE_ENV = 'production'
|
56 |
|
57 | const { configs } = webpackBase({
|
58 | target: 'electron-renderer',
|
59 | paths: { context: '/test' },
|
60 | })
|
61 | expect(configs).toMatchSnapshot()
|
62 | })
|
63 | })
|