|
| 1 | +/** |
| 2 | + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + */ |
| 7 | + |
| 8 | +import * as path from 'path'; |
| 9 | +import {wrap} from 'jest-snapshot-serializer-raw'; |
| 10 | +import slash = require('slash'); |
| 11 | +import {extractSummary} from '../Utils'; |
| 12 | +import runJest from '../runJest'; |
| 13 | + |
| 14 | +const MULTIPLE_CONFIGS_WARNING_TEXT = 'Multiple configurations found'; |
| 15 | + |
| 16 | +test('multiple configs will warn', () => { |
| 17 | + const rootDir = slash(path.resolve(__dirname, '../..')); |
| 18 | + const {exitCode, stderr} = runJest('multiple-configs', [], { |
| 19 | + skipPkgJsonCheck: true, |
| 20 | + }); |
| 21 | + |
| 22 | + expect(exitCode).toBe(0); |
| 23 | + expect(stderr).toContain(MULTIPLE_CONFIGS_WARNING_TEXT); |
| 24 | + |
| 25 | + const cleanStdErr = stderr.replace(new RegExp(rootDir, 'g'), '<rootDir>'); |
| 26 | + const {rest, summary} = extractSummary(cleanStdErr); |
| 27 | + |
| 28 | + expect(wrap(rest)).toMatchSnapshot(); |
| 29 | + expect(wrap(summary)).toMatchSnapshot(); |
| 30 | +}); |
| 31 | + |
| 32 | +test('multiple configs warning can be suppressed by using --config', () => { |
| 33 | + const {exitCode, stderr} = runJest( |
| 34 | + 'multiple-configs', |
| 35 | + ['--config', 'jest.config.json'], |
| 36 | + { |
| 37 | + skipPkgJsonCheck: true, |
| 38 | + }, |
| 39 | + ); |
| 40 | + |
| 41 | + expect(exitCode).toBe(0); |
| 42 | + expect(stderr).not.toContain(MULTIPLE_CONFIGS_WARNING_TEXT); |
| 43 | +}); |
0 commit comments