-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b44e7f2
commit d4712c4
Showing
3 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
e2e/__tests__/__snapshots__/watch_mode_no_access.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`does not re-run tests when only access time is modified 1`] = ` | ||
Array [ | ||
"Test Suites: 1 passed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites.", | ||
"Test Suites: 1 passed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites.", | ||
"Test Suites: 1 passed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites.", | ||
"Test Suites: 1 failed, 1 total | ||
Tests: 1 failed, 1 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites. | ||
", | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import fs from 'fs'; | ||
import os from 'os'; | ||
import path from 'path'; | ||
import {cleanup, extractSummaries, writeFiles} from '../Utils'; | ||
import {until as runJestUntil} from '../runJest'; | ||
|
||
const DIR = path.resolve(os.tmpdir(), 'watch_mode_no_access'); | ||
|
||
const sleep = time => new Promise(resolve => setTimeout(resolve, time)); | ||
|
||
beforeEach(() => cleanup(DIR)); | ||
afterAll(() => cleanup(DIR)); | ||
|
||
const setupFiles = () => { | ||
writeFiles(DIR, { | ||
'__tests__/foo.spec.js': ` | ||
const foo = require('../foo'); | ||
test('foo', () => { expect(typeof foo).toBe('number'); }); | ||
`, | ||
'foo.js': ` | ||
module.exports = 0; | ||
`, | ||
'package.json': JSON.stringify({ | ||
jest: {}, | ||
}), | ||
}); | ||
}; | ||
|
||
test('does not re-run tests when only access time is modified', async () => { | ||
setupFiles(); | ||
|
||
const testRun = runJestUntil(DIR, ['--watchAll', '--no-watchman'], '1 failed, 1 total'); | ||
|
||
await sleep(1000); | ||
|
||
// Should re-run the test | ||
const modulePath = path.join(DIR, 'foo.js'); | ||
const stat = fs.lstatSync(modulePath); | ||
fs.utimesSync(modulePath, stat.atime, stat.mtime); | ||
|
||
await sleep(1000); | ||
|
||
// Should not re-run the test | ||
const fakeATime = 1541723621; | ||
fs.utimesSync(modulePath, fakeATime, stat.mtime); | ||
|
||
await sleep(1000); | ||
|
||
// Should re-run the test | ||
fs.writeFileSync(modulePath, 'module.exports = 1;', {encoding: 'utf-8'}); | ||
|
||
await sleep(1000); | ||
|
||
// Should make the test fail and finish the process | ||
fs.writeFileSync(modulePath, 'module.exports = undefined;', { | ||
encoding: 'utf-8', | ||
}); | ||
|
||
const {stderr} = await testRun; | ||
const results = extractSummaries(stderr); | ||
|
||
// initial YES, mtime YES, atime NO, mtime YES, fail YES | ||
expect(results).toHaveLength(4); | ||
expect(results.map(result => result.summary)).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters