forked from jestjs/jest
/
multipleConfigs.ts
43 lines (35 loc) · 1.27 KB
/
multipleConfigs.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 * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import slash = require('slash');
import {extractSummary} from '../Utils';
import runJest from '../runJest';
const MULTIPLE_CONFIGS_WARNING_TEXT = 'Multiple configurations found';
test('multiple configs will warn', () => {
const rootDir = slash(path.resolve(__dirname, '../..'));
const {exitCode, stderr} = runJest('multiple-configs', [], {
skipPkgJsonCheck: true,
});
expect(exitCode).toBe(0);
expect(stderr).toContain(MULTIPLE_CONFIGS_WARNING_TEXT);
const cleanStdErr = stderr.replace(new RegExp(rootDir, 'g'), '<rootDir>');
const {rest, summary} = extractSummary(cleanStdErr);
expect(wrap(rest)).toMatchSnapshot();
expect(wrap(summary)).toMatchSnapshot();
});
test('multiple configs warning can be suppressed by using --config', () => {
const {exitCode, stderr} = runJest(
'multiple-configs',
['--config', 'jest.config.json'],
{
skipPkgJsonCheck: true,
},
);
expect(exitCode).toBe(0);
expect(stderr).not.toContain(MULTIPLE_CONFIGS_WARNING_TEXT);
});