forked from jestjs/jest
/
showConfig.test.ts
44 lines (37 loc) · 1.46 KB
/
showConfig.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
/**
* 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 {cleanup, writeFiles} from '../Utils';
import runJest from '../runJest';
const DIR = path.resolve(tmpdir(), 'show-config-test');
beforeEach(() => cleanup(DIR));
afterEach(() => cleanup(DIR));
test('--showConfig outputs config info and exits', () => {
writeFiles(DIR, {
'__tests__/test.test.js': "test('test', () => {});",
'package.json': JSON.stringify({jest: {environment: 'node'}}),
});
let {stdout} = runJest(DIR, [
'--showConfig',
'--no-cache',
// Make the snapshot flag stable on CI.
'--ci',
]);
stdout = stdout
.replace(/\\\\node_modules\\\\/g, 'node_modules')
.replace(/\\\\\.pnp\\\\\.\[\^[/\\]+\]\+\$/g, '<<REPLACED_PNP_PATH>>')
.replace(/\\\\(?:([^.]+?)|$)/g, '/$1')
.replace(/"cacheDirectory": "(.+)"/g, '"cacheDirectory": "/tmp/jest"')
.replace(/"id": "(.+)"/g, '"id": "[md5 hash]"')
.replace(/"version": "(.+)"/g, '"version": "[version]"')
.replace(/"maxWorkers": (\d+)/g, '"maxWorkers": "[maxWorkers]"')
.replace(/"\S*show-config-test/gm, '"<<REPLACED_ROOT_DIR>>')
.replace(/"\S*\/jest\/packages/gm, '"<<REPLACED_JEST_PACKAGES_DIR>>')
.replace(/"seed": (-?\d+)/g, '"seed": <<RANDOM_SEED>>');
expect(stdout).toMatchSnapshot();
});