@@ -32,89 +32,79 @@ 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 (
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
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
42
57
) ;
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
62
- ) ;
58
+ }
59
+ webpack ( webpackConfig , ( err , stats ) => {
60
+ if ( err ) {
61
+ done ( err ) ;
62
+ return ;
63
63
}
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'
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
+ )
93
82
) ;
83
+ return ;
84
+ }
85
+ const expectedDirectory = path . resolve ( directoryForCase , 'expected' ) ;
94
86
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' ) ;
87
+ for ( const file of walkSync ( expectedDirectory ) ) {
88
+ const actualFilePath = file . replace (
89
+ new RegExp ( `/cases/${ directory } /expected/` ) ,
90
+ `/js/${ directory } /`
91
+ ) ;
92
+ const expectedContent = fs . readFileSync ( file , 'utf-8' ) ;
93
+ const actualContent = fs . readFileSync ( actualFilePath , 'utf-8' ) ;
102
94
103
- expect ( actualContent ) . toEqual ( expectedContent ) ;
104
- }
105
- done ( ) ;
106
- } ) ;
107
- } ,
108
- 10000
109
- ) ;
95
+ expect ( actualContent ) . toEqual ( expectedContent ) ;
96
+ }
97
+ done ( ) ;
98
+ } ) ;
99
+ } , 10000 ) ;
110
100
}
111
101
}
112
102
} ) ;
113
103
114
104
/**
115
105
* Synchronously traverse directory of files
116
106
* @param {String } dir
117
- * @returns {String } // path to file or directory
107
+ * @returns {String } path to file or directory
118
108
*/
119
109
function * walkSync ( dir ) {
120
110
for ( const file of fs . readdirSync ( dir ) ) {
0 commit comments