99
1010'use strict' ;
1111
12- import fs from 'fs ' ;
13- import os from 'os ' ;
14- import path from 'path ' ;
12+ import * as os from 'os ' ;
13+ import * as path from 'path ' ;
14+ import * as fs from 'graceful-fs ' ;
1515import { cleanup , writeFiles } from '../Utils' ;
1616import { runContinuous } from '../runJest' ;
1717
1818const DIR = path . resolve ( os . tmpdir ( ) , 'watch_mode_no_access' ) ;
1919
20- const sleep = time => new Promise ( resolve => setTimeout ( resolve , time ) ) ;
20+ const sleep = ( time : number ) =>
21+ new Promise ( resolve => setTimeout ( resolve , time ) ) ;
2122
2223beforeEach ( ( ) => cleanup ( DIR ) ) ;
2324afterAll ( ( ) => cleanup ( DIR ) ) ;
2425
2526const setupFiles = ( ) => {
2627 writeFiles ( DIR , {
27- '__tests__/foo.spec .js' : `
28+ '__tests__/foo.test .js' : `
2829 const foo = require('../foo');
2930 test('foo', () => { expect(typeof foo).toBe('number'); });
3031 ` ,
@@ -37,7 +38,7 @@ const setupFiles = () => {
3738 } ) ;
3839} ;
3940
40- let testRun ;
41+ let testRun : ReturnType < typeof runContinuous > ;
4142
4243afterEach ( async ( ) => {
4344 if ( testRun ) {
@@ -62,12 +63,13 @@ test('does not re-run tests when only access time is modified', async () => {
6263 // Should re-run the test
6364 const modulePath = path . join ( DIR , 'foo.js' ) ;
6465 const stat = fs . lstatSync ( modulePath ) ;
65- fs . utimesSync ( modulePath , stat . atime , stat . mtime ) ;
66+ fs . utimesSync ( modulePath , stat . atime . getTime ( ) , stat . mtime . getTime ( ) ) ;
67+
6668 await testRun . waitUntil ( ( { stderr} ) => numberOfTestRuns ( stderr ) === 2 ) ;
6769
6870 // Should NOT re-run the test
6971 const fakeATime = 1541723621 ;
70- fs . utimesSync ( modulePath , fakeATime , stat . mtime ) ;
72+ fs . utimesSync ( modulePath , fakeATime , stat . mtime . getTime ( ) ) ;
7173 await sleep ( 3000 ) ;
7274 expect ( numberOfTestRuns ( testRun . getCurrentOutput ( ) . stderr ) ) . toBe ( 2 ) ;
7375
0 commit comments