@@ -59,18 +59,33 @@ describe('TestCases', () => {
59
59
) ;
60
60
return ;
61
61
}
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'
67
- ) ;
68
- const actualContent = fs . readFileSync (
69
- path . resolve ( outputDirectoryForCase , file ) ,
70
- 'utf-8'
71
- ) ;
72
- expect ( actualContent ) . toEqual ( content ) ;
62
+
63
+ function compareDirectory ( actual , expected ) {
64
+ for ( const file of fs . readdirSync ( expected , {
65
+ withFileTypes : true ,
66
+ } ) ) {
67
+ if ( file . isFile ( ) ) {
68
+ const content = fs . readFileSync (
69
+ path . resolve ( expected , file . name ) ,
70
+ 'utf-8'
71
+ ) ;
72
+ const actualContent = fs . readFileSync (
73
+ path . resolve ( actual , file . name ) ,
74
+ 'utf-8'
75
+ ) ;
76
+ expect ( actualContent ) . toEqual ( content ) ;
77
+ } else if ( file . isDirectory ( ) ) {
78
+ compareDirectory (
79
+ path . resolve ( actual , file . name ) ,
80
+ path . resolve ( expected , file . name )
81
+ ) ;
82
+ }
83
+ }
73
84
}
85
+
86
+ const expectedDirectory = path . resolve ( directoryForCase , 'expected' ) ;
87
+ compareDirectory ( outputDirectoryForCase , expectedDirectory ) ;
88
+
74
89
done ( ) ;
75
90
} ) ;
76
91
} , 10000 ) ;
0 commit comments