1
- import { getCompiler , compile } from './helpers' ;
2
-
3
- jest . mock ( 'webpack' ) ;
4
- jest . mock ( 'webpack/lib/node/NodeTargetPlugin' ) ;
1
+ import { getCompiler , source , compile } from './helpers' ;
5
2
6
3
it ( 'should enforce esm for empty module with options.esModule' , async ( done ) => {
7
4
const compiler = getCompiler (
@@ -14,18 +11,14 @@ it('should enforce esm for empty module with options.esModule', async (done) =>
14
11
) ;
15
12
const stats = await compile ( compiler ) ;
16
13
expect ( stats . hasErrors ( ) ) . toBe ( false ) ;
17
-
18
- const { chunks } = stats . toJson ( ) ;
19
- const [ chunk ] = chunks ;
20
-
21
- expect ( JSON . stringify ( chunk . sizes ) ) . toMatchInlineSnapshot (
22
- // javascript size is mostly a webpack info comments
23
- `"{\\"javascript\\":73,\\"unknown\\":23,\\"runtime\\":0}"`
24
- ) ;
14
+ expect ( source ( './simple.css' , stats ) ) . toMatchInlineSnapshot ( `
15
+ "// extracted by mini-css-extract-plugin
16
+ export {};"
17
+ ` ) ;
25
18
done ( ) ;
26
19
} ) ;
27
20
28
- it ( 'should keep module without options.esModule' , async ( done ) => {
21
+ it ( 'should keep empty module without options.esModule' , async ( done ) => {
29
22
const compiler = getCompiler (
30
23
'./esm.js' ,
31
24
{ } ,
@@ -36,13 +29,8 @@ it('should keep module without options.esModule', async (done) => {
36
29
) ;
37
30
const stats = await compile ( compiler ) ;
38
31
expect ( stats . hasErrors ( ) ) . toBe ( false ) ;
39
-
40
- const { chunks } = stats . toJson ( ) ;
41
- const [ chunk ] = chunks ;
42
-
43
- expect ( JSON . stringify ( chunk . sizes ) ) . toMatchInlineSnapshot (
44
- // javascript size is mostly a webpack info comments
45
- `"{\\"javascript\\":62,\\"unknown\\":23,\\"runtime\\":657}"`
32
+ expect ( source ( './simple.css' , stats ) ) . toMatchInlineSnapshot (
33
+ `"// extracted by mini-css-extract-plugin"`
46
34
) ;
47
35
done ( ) ;
48
36
} ) ;
0 commit comments