-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make jest-haste-map compute SHA-1s for excluded files too (as watchma…
…n does) (#6264)
- Loading branch information
Showing
5 changed files
with
180 additions
and
52 deletions.
There are no files selected for viewing
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
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,81 @@ | ||
/** | ||
* 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 os from 'os'; | ||
import path from 'path'; | ||
import JestHasteMap from 'jest-haste-map'; | ||
const {cleanup, writeFiles} = require('../Utils'); | ||
|
||
const DIR = path.resolve(os.tmpdir(), 'haste_map_sha1'); | ||
|
||
beforeEach(() => cleanup(DIR)); | ||
afterEach(() => cleanup(DIR)); | ||
|
||
test('exits the process after test are done but before timers complete', async () => { | ||
writeFiles(DIR, { | ||
'file.android.js': '"foo android"', | ||
'file.ios.js': '"foo ios"', | ||
'file.js': '"foo default"', | ||
'file_with_extension.ignored': '"ignored file"', | ||
'node_modules/bar/file_with_extension.ignored': '"ignored node modules"', | ||
'node_modules/bar/image.png': '"an image"', | ||
'node_modules/bar/index.js': '"node modules bar"', | ||
}); | ||
|
||
const haste = new JestHasteMap({ | ||
computeSha1: true, | ||
extensions: ['js', 'json', 'png'], | ||
forceNodeFilesystemAPI: true, | ||
ignorePattern: / ^/, | ||
maxWorkers: 2, | ||
mocksPattern: '', | ||
name: 'tmp', | ||
platforms: ['ios', 'android'], | ||
retainAllFiles: true, | ||
roots: [DIR], | ||
useWatchman: false, | ||
watch: false, | ||
}); | ||
|
||
const {hasteFS} = await haste.build(); | ||
|
||
expect(hasteFS.getSha1(path.join(DIR, 'file.android.js'))).toBe( | ||
'e376f9fd9a96d000fa019020159f996a8855f8bc', | ||
); | ||
|
||
expect(hasteFS.getSha1(path.join(DIR, 'file.ios.js'))).toBe( | ||
'1271b4db2a5f47ae46cb01a1d0604a94d401e8f7', | ||
); | ||
|
||
expect(hasteFS.getSha1(path.join(DIR, 'file.js'))).toBe( | ||
'c26c852220977244418f17a9fdc4ae9c192b3188', | ||
); | ||
|
||
expect(hasteFS.getSha1(path.join(DIR, 'node_modules/bar/image.png'))).toBe( | ||
'8688f7e11f63d8a7eac7cb87af850337fabbd400', | ||
); | ||
|
||
expect(hasteFS.getSha1(path.join(DIR, 'node_modules/bar/index.js'))).toBe( | ||
'ee245b9fbd45e1f6ad300eb2f5484844f6b5a34c', | ||
); | ||
|
||
// Ignored files do not get the SHA-1 computed. | ||
|
||
expect(hasteFS.getSha1(path.join(DIR, 'file_with_extension.ignored'))).toBe( | ||
null, | ||
); | ||
|
||
expect( | ||
hasteFS.getSha1( | ||
path.join(DIR, 'node_modules/bar/file_with_extension.ignored'), | ||
), | ||
).toBe(null); | ||
}); |
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
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
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