/
crawlSymlinks.test.ts
43 lines (38 loc) · 1.14 KB
/
crawlSymlinks.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
/**
* 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 {tmpdir} from 'os';
import * as path from 'path';
import * as fs from 'fs';
import {writeFiles, writeSymlinks} from '../Utils';
import runJest from '../runJest';
const DIR = path.resolve(tmpdir(), 'crawl-symlinks-test');
test('Node crawler picks up symlinked files', () => {
if (fs.existsSync(DIR)) {
fs.rmdirSync(DIR, {recursive: true});
}
writeFiles(DIR, {
'package.json': `
{
"jest": {
"testMatch": ["<rootDir>/test-files/test.js"]
}
}
`,
'symlinked-files/test.js': `
test('1+1', () => {
expect(1).toBe(1);
});
`,
});
writeSymlinks(DIR, {
'symlinked-files/test.js': 'test-files/test.js',
});
const {stdout, stderr, exitCode} = runJest(DIR, ['--no-watchman']);
expect(stderr).toContain('Test Suites: 1 passed, 1 total');
expect(stdout).toEqual('');
expect(exitCode).toEqual(0);
});