@@ -9,81 +9,71 @@ 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 (
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
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
19
34
) ;
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
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
+ )
39
59
) ;
60
+ return ;
40
61
}
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
- } )
62
+ const expectedDirectory = path . resolve ( directoryForCase , 'expected' ) ;
63
+ for ( const file of fs . readdirSync ( expectedDirectory ) ) {
64
+ const content = fs . readFileSync (
65
+ path . resolve ( expectedDirectory , file ) ,
66
+ 'utf-8'
55
67
) ;
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
+ const actualContent = fs . readFileSync (
69
+ path . resolve ( outputDirectoryForCase , file ) ,
70
+ 'utf-8'
70
71
) ;
71
- for ( const file of fs . readdirSync ( expectedDirectory ) ) {
72
- const content = fs . readFileSync (
73
- path . resolve ( expectedDirectory , file ) ,
74
- 'utf-8'
75
- ) ;
76
- const actualContent = fs . readFileSync (
77
- path . resolve ( outputDirectoryForCase , file ) ,
78
- 'utf-8'
79
- ) ;
80
- expect ( actualContent ) . toEqual ( content ) ;
81
- }
82
- done ( ) ;
83
- } ) ;
84
- } ,
85
- 10000
86
- ) ;
72
+ expect ( actualContent ) . toEqual ( content ) ;
73
+ }
74
+ done ( ) ;
75
+ } ) ;
76
+ } , 10000 ) ;
87
77
}
88
78
}
89
79
} ) ;
0 commit comments