forked from jestjs/jest
/
hasteMapMockChanged.test.ts
47 lines (41 loc) 路 1.26 KB
/
hasteMapMockChanged.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Copyright (c) Facebook, Inc. and its affiliates. 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.
*/
import * as path from 'path';
import JestHasteMap from 'jest-haste-map';
import {cleanup, writeFiles} from '../Utils';
// Directory must be here for Watchman to be enabled.
const DIR = path.resolve(__dirname, 'haste_map_mock_changed');
beforeEach(() => cleanup(DIR));
afterEach(() => cleanup(DIR));
test('should not warn when a mock file changes', async () => {
const hasteConfig = {
computeSha1: false,
extensions: ['js', 'json', 'png'],
forceNodeFilesystemAPI: false,
ignorePattern: / ^/,
maxWorkers: 2,
mocksPattern: '__mocks__',
name: 'tmp_' + Date.now(),
platforms: [],
retainAllFiles: false,
rootDir: DIR,
roots: [DIR],
throwOnModuleCollision: true,
useWatchman: true,
watch: false,
};
// Populate the cache.
writeFiles(DIR, {
'__mocks__/fs.js': '"foo fs"',
});
await new JestHasteMap(hasteConfig).build();
// This will throw if the mock file being updated triggers a warning.
writeFiles(DIR, {
'__mocks__/fs.js': '"foo fs!"',
});
await new JestHasteMap(hasteConfig).build();
});