@@ -9,71 +9,81 @@ describe('TestCases', () => {
9
9
for ( const directory of fs . readdirSync ( casesDirectory ) ) {
10
10
if ( ! / ^ ( \. | _ ) / . test ( directory ) ) {
11
11
// eslint-disable-next-line no-loop-func
12
- it ( `${ directory } should compile to the expected result` , ( done ) => {
13
- const directoryForCase = path . resolve ( casesDirectory , directory ) ;
14
- const outputDirectoryForCase = path . resolve ( outputDirectory , directory ) ;
15
- // eslint-disable-next-line import/no-dynamic-require, global-require
16
- const webpackConfig = require ( path . resolve (
17
- directoryForCase ,
18
- 'webpack.config.js'
19
- ) ) ;
20
- for ( const config of [ ] . concat ( webpackConfig ) ) {
21
- Object . assign (
22
- config ,
23
- {
24
- mode : 'none' ,
25
- context : directoryForCase ,
26
- output : Object . assign (
27
- {
28
- path : outputDirectoryForCase ,
29
- } ,
30
- config . output
31
- ) ,
32
- } ,
33
- config
12
+ it (
13
+ `${ directory } should compile to the expected result` ,
14
+ ( done ) => {
15
+ const directoryForCase = path . resolve ( casesDirectory , directory ) ;
16
+ const outputDirectoryForCase = path . resolve (
17
+ outputDirectory ,
18
+ directory
34
19
) ;
35
- }
36
- webpack ( webpackConfig , ( err , stats ) => {
37
- if ( err ) {
38
- done ( err ) ;
39
- return ;
40
- }
41
- done ( ) ;
42
- // eslint-disable-next-line no-console
43
- console . log (
44
- stats . toString ( {
45
- context : path . resolve ( __dirname , '..' ) ,
46
- chunks : true ,
47
- chunkModules : true ,
48
- modules : false ,
49
- } )
50
- ) ;
51
- if ( stats . hasErrors ( ) ) {
52
- done (
53
- new Error (
54
- stats . toString ( {
55
- context : path . resolve ( __dirname , '..' ) ,
56
- errorDetails : true ,
57
- } )
58
- )
20
+ // eslint-disable-next-line import/no-dynamic-require, global-require
21
+ const webpackConfig = require ( path . resolve (
22
+ directoryForCase ,
23
+ 'webpack.config.js'
24
+ ) ) ;
25
+ for ( const config of [ ] . concat ( webpackConfig ) ) {
26
+ Object . assign (
27
+ config ,
28
+ {
29
+ mode : 'none' ,
30
+ context : directoryForCase ,
31
+ output : Object . assign (
32
+ {
33
+ path : outputDirectoryForCase ,
34
+ } ,
35
+ config . output
36
+ ) ,
37
+ } ,
38
+ config
59
39
) ;
60
- return ;
61
40
}
62
- const expectedDirectory = path . resolve ( directoryForCase , 'expected' ) ;
63
-
64
- for ( const file of walkSync ( expectedDirectory ) ) {
65
- const actualFilePath = file . replace (
66
- new RegExp ( `/cases/${ directory } /expected/` ) ,
67
- `/js/${ directory } /`
41
+ webpack ( webpackConfig , ( err , stats ) => {
42
+ if ( err ) {
43
+ done ( err ) ;
44
+ return ;
45
+ }
46
+ done ( ) ;
47
+ // eslint-disable-next-line no-console
48
+ console . log (
49
+ stats . toString ( {
50
+ context : path . resolve ( __dirname , '..' ) ,
51
+ chunks : true ,
52
+ chunkModules : true ,
53
+ modules : false ,
54
+ } )
55
+ ) ;
56
+ if ( stats . hasErrors ( ) ) {
57
+ done (
58
+ new Error (
59
+ stats . toString ( {
60
+ context : path . resolve ( __dirname , '..' ) ,
61
+ errorDetails : true ,
62
+ } )
63
+ )
64
+ ) ;
65
+ return ;
66
+ }
67
+ const expectedDirectory = path . resolve (
68
+ directoryForCase ,
69
+ 'expected'
68
70
) ;
69
- const expectedContent = fs . readFileSync ( file , 'utf-8' ) ;
70
- const actualContent = fs . readFileSync ( actualFilePath , 'utf-8' ) ;
71
71
72
- expect ( actualContent ) . toEqual ( expectedContent ) ;
73
- }
74
- done ( ) ;
75
- } ) ;
76
- } , 10000 ) ;
72
+ for ( const file of walkSync ( expectedDirectory ) ) {
73
+ const actualFilePath = file . replace (
74
+ new RegExp ( `/cases/${ directory } /expected/` ) ,
75
+ `/js/${ directory } /`
76
+ ) ;
77
+ const expectedContent = fs . readFileSync ( file , 'utf-8' ) ;
78
+ const actualContent = fs . readFileSync ( actualFilePath , 'utf-8' ) ;
79
+
80
+ expect ( actualContent ) . toEqual ( expectedContent ) ;
81
+ }
82
+ done ( ) ;
83
+ } ) ;
84
+ } ,
85
+ 10000
86
+ ) ;
77
87
}
78
88
}
79
89
} ) ;
0 commit comments