/
import-option.test.js
34 lines (30 loc) · 1.19 KB
/
import-option.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const { webpack, evaluated, normalizeErrors } = require('./helpers');
describe('import option', () => {
it('true', async () => {
const testId = './import/import.css';
const stats = await webpack(testId);
const { modules } = stats.toJson();
const module = modules.find((m) => m.id === testId);
expect(module.source).toMatchSnapshot('module');
expect(evaluated(module.source, modules)).toMatchSnapshot(
'module (evaluated)'
);
expect(normalizeErrors(stats.compilation.warnings)).toMatchSnapshot(
'warnings'
);
expect(normalizeErrors(stats.compilation.errors)).toMatchSnapshot('errors');
});
it('false', async () => {
const config = { loader: { options: { import: false } } };
const testId = './import/import.css';
const stats = await webpack(testId, config);
const { modules } = stats.toJson();
const module = modules.find((m) => m.id === testId);
expect(module.source).toMatchSnapshot('module');
expect(evaluated(module.source, modules)).toMatchSnapshot(
'module (evaluated)'
);
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
expect(stats.compilation.errors).toMatchSnapshot('errors');
});
});