@@ -32,71 +32,81 @@ describe('TestCases', () => {
32
32
for ( const directory of fs . readdirSync ( casesDirectory ) ) {
33
33
if ( ! / ^ ( \. | _ ) / . test ( directory ) ) {
34
34
// eslint-disable-next-line no-loop-func
35
- it ( `${ directory } should compile to the expected result` , ( done ) => {
36
- const directoryForCase = path . resolve ( casesDirectory , directory ) ;
37
- const outputDirectoryForCase = path . resolve ( outputDirectory , directory ) ;
38
- // eslint-disable-next-line import/no-dynamic-require, global-require
39
- const webpackConfig = require ( path . resolve (
40
- directoryForCase ,
41
- 'webpack.config.js'
42
- ) ) ;
43
- for ( const config of [ ] . concat ( webpackConfig ) ) {
44
- Object . assign (
45
- config ,
46
- {
47
- mode : 'none' ,
48
- context : directoryForCase ,
49
- output : Object . assign (
50
- {
51
- path : outputDirectoryForCase ,
52
- } ,
53
- config . output
54
- ) ,
55
- } ,
56
- config
35
+ it (
36
+ `${ directory } should compile to the expected result` ,
37
+ ( done ) => {
38
+ const directoryForCase = path . resolve ( casesDirectory , directory ) ;
39
+ const outputDirectoryForCase = path . resolve (
40
+ outputDirectory ,
41
+ directory
57
42
) ;
58
- }
59
- webpack ( webpackConfig , ( err , stats ) => {
60
- if ( err ) {
61
- done ( err ) ;
62
- return ;
63
- }
64
- done ( ) ;
65
- // eslint-disable-next-line no-console
66
- console . log (
67
- stats . toString ( {
68
- context : path . resolve ( __dirname , '..' ) ,
69
- chunks : true ,
70
- chunkModules : true ,
71
- modules : false ,
72
- } )
73
- ) ;
74
- if ( stats . hasErrors ( ) ) {
75
- done (
76
- new Error (
77
- stats . toString ( {
78
- context : path . resolve ( __dirname , '..' ) ,
79
- errorDetails : true ,
80
- } )
81
- )
43
+ // eslint-disable-next-line import/no-dynamic-require, global-require
44
+ const webpackConfig = require ( path . resolve (
45
+ directoryForCase ,
46
+ 'webpack.config.js'
47
+ ) ) ;
48
+ for ( const config of [ ] . concat ( webpackConfig ) ) {
49
+ Object . assign (
50
+ config ,
51
+ {
52
+ mode : 'none' ,
53
+ context : directoryForCase ,
54
+ output : Object . assign (
55
+ {
56
+ path : outputDirectoryForCase ,
57
+ } ,
58
+ config . output
59
+ ) ,
60
+ } ,
61
+ config
82
62
) ;
83
- return ;
84
63
}
85
- const expectedDirectory = path . resolve ( directoryForCase , 'expected' ) ;
86
-
87
- for ( const file of walkSync ( expectedDirectory ) ) {
88
- const actualFilePath = file . replace (
89
- new RegExp ( `/cases/${ directory } /expected/` ) ,
90
- `/js/${ directory } /`
64
+ webpack ( webpackConfig , ( err , stats ) => {
65
+ if ( err ) {
66
+ done ( err ) ;
67
+ return ;
68
+ }
69
+ done ( ) ;
70
+ // eslint-disable-next-line no-console
71
+ console . log (
72
+ stats . toString ( {
73
+ context : path . resolve ( __dirname , '..' ) ,
74
+ chunks : true ,
75
+ chunkModules : true ,
76
+ modules : false ,
77
+ } )
78
+ ) ;
79
+ if ( stats . hasErrors ( ) ) {
80
+ done (
81
+ new Error (
82
+ stats . toString ( {
83
+ context : path . resolve ( __dirname , '..' ) ,
84
+ errorDetails : true ,
85
+ } )
86
+ )
87
+ ) ;
88
+ return ;
89
+ }
90
+ const expectedDirectory = path . resolve (
91
+ directoryForCase ,
92
+ 'expected'
91
93
) ;
92
- const expectedContent = fs . readFileSync ( file , 'utf-8' ) ;
93
- const actualContent = fs . readFileSync ( actualFilePath , 'utf-8' ) ;
94
94
95
- expect ( actualContent ) . toEqual ( expectedContent ) ;
96
- }
97
- done ( ) ;
98
- } ) ;
99
- } , 10000 ) ;
95
+ for ( const file of walkSync ( expectedDirectory ) ) {
96
+ const actualFilePath = file . replace (
97
+ new RegExp ( `/cases/${ directory } /expected/` ) ,
98
+ `/js/${ directory } /`
99
+ ) ;
100
+ const expectedContent = fs . readFileSync ( file , 'utf-8' ) ;
101
+ const actualContent = fs . readFileSync ( actualFilePath , 'utf-8' ) ;
102
+
103
+ expect ( actualContent ) . toEqual ( expectedContent ) ;
104
+ }
105
+ done ( ) ;
106
+ } ) ;
107
+ } ,
108
+ 10000
109
+ ) ;
100
110
}
101
111
}
102
112
} ) ;
0 commit comments