@@ -5,6 +5,7 @@ const path = require("path");
55const fs = require ( "fs" ) ;
66const vm = require ( "vm" ) ;
77const mkdirp = require ( "mkdirp" ) ;
8+ const rimraf = require ( "rimraf" ) ;
89const checkArrayExpectation = require ( "./checkArrayExpectation" ) ;
910const { remove } = require ( "./helpers/remove" ) ;
1011
@@ -76,9 +77,7 @@ describe("WatchTestCases", () => {
7677 "js" ,
7778 "watch-src" ,
7879 category . name ,
79- `${ testName } -${ Math . random ( )
80- . toPrecision ( 21 )
81- . slice ( 2 ) } `
80+ testName
8281 ) ;
8382 const testDirectory = path . join ( casesPath , category . name , testName ) ;
8483 const runs = fs
@@ -89,7 +88,9 @@ describe("WatchTestCases", () => {
8988 } )
9089 . map ( name => ( { name } ) ) ;
9190
92- let exportedTests = [ ] ;
91+ beforeAll ( done => {
92+ rimraf ( tempDirectory , done ) ;
93+ } ) ;
9394
9495 it (
9596 testName + " should compile" ,
@@ -201,6 +202,8 @@ describe("WatchTestCases", () => {
201202 )
202203 return ;
203204
205+ const exportedTests = [ ] ;
206+
204207 function _it ( title , fn ) {
205208 exportedTests . push ( { title, fn, timeout : 45000 } ) ;
206209 }
@@ -293,38 +296,43 @@ describe("WatchTestCases", () => {
293296 if ( exportedTests . length < 1 )
294297 return done ( new Error ( "No tests exported by test case" ) ) ;
295298
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 ( ) ;
311315
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+ } ;
322319
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 ) ;
328336 }
329337 ) ;
330338 } , 300 ) ;
0 commit comments