@@ -5,6 +5,7 @@ const path = require("path");
5
5
const fs = require ( "fs" ) ;
6
6
const vm = require ( "vm" ) ;
7
7
const mkdirp = require ( "mkdirp" ) ;
8
+ const rimraf = require ( "rimraf" ) ;
8
9
const checkArrayExpectation = require ( "./checkArrayExpectation" ) ;
9
10
const { remove } = require ( "./helpers/remove" ) ;
10
11
@@ -76,9 +77,7 @@ describe("WatchTestCases", () => {
76
77
"js" ,
77
78
"watch-src" ,
78
79
category . name ,
79
- `${ testName } -${ Math . random ( )
80
- . toPrecision ( 21 )
81
- . slice ( 2 ) } `
80
+ testName
82
81
) ;
83
82
const testDirectory = path . join ( casesPath , category . name , testName ) ;
84
83
const runs = fs
@@ -89,7 +88,9 @@ describe("WatchTestCases", () => {
89
88
} )
90
89
. map ( name => ( { name } ) ) ;
91
90
92
- let exportedTests = [ ] ;
91
+ beforeAll ( done => {
92
+ rimraf ( tempDirectory , done ) ;
93
+ } ) ;
93
94
94
95
it (
95
96
testName + " should compile" ,
@@ -201,6 +202,8 @@ describe("WatchTestCases", () => {
201
202
)
202
203
return ;
203
204
205
+ const exportedTests = [ ] ;
206
+
204
207
function _it ( title , fn ) {
205
208
exportedTests . push ( { title, fn, timeout : 45000 } ) ;
206
209
}
@@ -293,38 +296,43 @@ describe("WatchTestCases", () => {
293
296
if ( exportedTests . length < 1 )
294
297
return done ( new Error ( "No tests exported by test case" ) ) ;
295
298
296
- runIdx ++ ;
297
- if ( runIdx < runs . length ) {
298
- run = runs [ runIdx ] ;
299
- waitMode = true ;
300
- setTimeout ( ( ) => {
301
- waitMode = false ;
302
- currentWatchStepModule . step = run . name ;
303
- copyDiff (
304
- path . join ( testDirectory , run . name ) ,
305
- tempDirectory ,
306
- false
307
- ) ;
308
- } , 1500 ) ;
309
- } else {
310
- watching . close ( ) ;
299
+ const continueStep = ( ) => {
300
+ runIdx ++ ;
301
+ if ( runIdx < runs . length ) {
302
+ run = runs [ runIdx ] ;
303
+ waitMode = true ;
304
+ setTimeout ( ( ) => {
305
+ waitMode = false ;
306
+ currentWatchStepModule . step = run . name ;
307
+ copyDiff (
308
+ path . join ( testDirectory , run . name ) ,
309
+ tempDirectory ,
310
+ false
311
+ ) ;
312
+ } , 1500 ) ;
313
+ } else {
314
+ watching . close ( ) ;
311
315
312
- const asyncSuite = describe ( "exported tests" , ( ) => {
313
- exportedTests . forEach (
314
- ( { title, fn, timeout } ) =>
315
- fn
316
- ? fit ( title , fn , timeout )
317
- : fit ( title , ( ) => { } ) . pend ( "Skipped" )
318
- ) ;
319
- } ) ;
320
- // workaround for jest running clearSpies on the wrong suite (invoked by clearResourcesForRunnable)
321
- asyncSuite . disabled = true ;
316
+ done ( ) ;
317
+ }
318
+ } ;
322
319
323
- jasmine
324
- . getEnv ( )
325
- . execute ( [ asyncSuite . id ] , asyncSuite )
326
- . then ( done , done ) ;
327
- }
320
+ // Run the tests
321
+ const asyncSuite = describe ( `step ${ run . name } ` , ( ) => {
322
+ exportedTests . forEach (
323
+ ( { title, fn, timeout } ) =>
324
+ fn
325
+ ? fit ( title , fn , timeout )
326
+ : fit ( title , ( ) => { } ) . pend ( "Skipped" )
327
+ ) ;
328
+ } ) ;
329
+ // workaround for jest running clearSpies on the wrong suite (invoked by clearResourcesForRunnable)
330
+ asyncSuite . disabled = true ;
331
+
332
+ jasmine
333
+ . getEnv ( )
334
+ . execute ( [ asyncSuite . id ] , asyncSuite )
335
+ . then ( continueStep , done ) ;
328
336
}
329
337
) ;
330
338
} , 300 ) ;
0 commit comments