@@ -25,7 +25,7 @@ interface WorkerThread {
25
25
}
26
26
27
27
const controllerDefaultOptions : TestControllerOptions = {
28
- testFileRegex : / .* ( t e s t | s p e c ) \. t s / gm,
28
+ testFileRegex : / .* ( t e s t | s p e c ) \. ( ( t s | j s ) x ? ) $ / gm,
29
29
} ;
30
30
31
31
interface WorkerControllerEventMap {
@@ -97,45 +97,41 @@ export class WorkerController extends BaseEventEmitter<
97
97
*/
98
98
public async findTestFiles ( rootDir : string ) : Promise < void > {
99
99
const controllerOptions = this . options ;
100
+ const testFiles = this . testFiles ;
100
101
101
- async function processDirectory (
102
- directoryPath : string ,
103
- ) : Promise < TestFile [ ] > {
102
+ async function processDirectory ( directoryPath : string ) : Promise < void > {
104
103
const directoryContents = await fs . readdir ( directoryPath , {
105
104
withFileTypes : true ,
106
105
encoding : 'utf-8' ,
107
106
} ) ;
108
107
109
- const testFiles = await Promise . all (
108
+ await Promise . all (
110
109
directoryContents . map ( async ( dirContent ) => {
111
110
const contentName = dirContent . name ;
112
111
const contentPath = resolvePath ( directoryPath , contentName ) ;
113
112
113
+ if ( controllerOptions . testFileRegex . test ( contentName ) ) {
114
+ testFiles . push (
115
+ new TestFile ( {
116
+ path : contentPath ,
117
+ } ) ,
118
+ ) ;
119
+
120
+ return ;
121
+ }
122
+
114
123
if ( contentName === 'node_modules' ) {
115
- return [ ] ;
124
+ return ;
116
125
}
117
126
118
127
if ( dirContent . isDirectory ( ) ) {
119
128
return processDirectory ( contentPath ) ;
120
129
}
121
-
122
- if ( controllerOptions . testFileRegex . test ( dirContent . name ) ) {
123
- return [
124
- new TestFile ( {
125
- path : contentPath ,
126
- } ) ,
127
- ] ;
128
- }
129
-
130
- return [ ] ;
131
130
} ) ,
132
131
) ;
133
-
134
- return testFiles . filter ( Boolean ) . flat ( ) ;
135
132
}
136
133
137
- const testFiles = await processDirectory ( rootDir ) ;
138
- this . testFiles . push ( ...testFiles ) ;
134
+ await processDirectory ( rootDir ) ;
139
135
}
140
136
141
137
/**
0 commit comments