/
fatalWorkerError.test.ts
46 lines (37 loc) · 1.23 KB
/
fatalWorkerError.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
/**
* 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 path from 'path';
import os from 'os';
import {cleanup, writeFiles} from '../Utils';
import runJest from '../runJest';
const DIR = path.resolve(os.tmpdir(), 'fatal-worker-error');
beforeEach(() => cleanup(DIR));
afterAll(() => cleanup(DIR));
const NUMBER_OF_TESTS_TO_FORCE_USING_WORKERS = 25;
test('fails a test that terminates the worker with a fatal error', () => {
const testFiles = {
'__tests__/fatalWorkerError.test.js': `
test('fatal worker error', () => {
process.exit(134);
});
`,
};
for (let i = 0; i <= NUMBER_OF_TESTS_TO_FORCE_USING_WORKERS; i++) {
testFiles[`__tests__/test${i}.test.js`] = `
test('test ${i}', () => {});
`;
}
writeFiles(DIR, {
...testFiles,
'package.json': '{}',
});
const expectedExitCode = os.platform() === 'darwin' ? 1 : 134;
const {status, stderr} = runJest(DIR);
expect(status).toBe(expectedExitCode);
expect(stderr).toContain('FAIL __tests__/fatalWorkerError.test.js');
expect(stderr).toContain('Call retries were exceeded');
});