Skip to content

Commit

Permalink
Change normalize tests to test testPathPatterns
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonchinn178 committed Sep 22, 2023
1 parent 4caaa45 commit 225b6fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ exports[`testMatch throws if testRegex and testMatch are both specified 1`] = `
<red></color>"
`;
exports[`testPathPattern <regexForTestFiles> ignores invalid regular expressions and logs a warning 1`] = `"<red> Invalid testPattern /a(/i supplied. Running all tests instead.</color>"`;
exports[`testPathPatterns <regexForTestFiles> ignores invalid regular expressions and logs a warning 1`] = `"<red> Invalid testPattern /a(/i supplied. Running all tests instead.</color>"`;
exports[`testPathPattern --testPathPattern ignores invalid regular expressions and logs a warning 1`] = `"<red> Invalid testPattern /a(/i supplied. Running all tests instead.</color>"`;
exports[`testPathPatterns --testPathPattern ignores invalid regular expressions and logs a warning 1`] = `"<red> Invalid testPattern /a(/i supplied. Running all tests instead.</color>"`;
exports[`testTimeout should throw an error if timeout is a negative number 1`] = `
"<red><bold><bold>● </intensity><bold>Validation Error</intensity>:</color>
Expand Down
14 changes: 7 additions & 7 deletions packages/jest-config/src/__tests__/normalize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,7 @@ describe('watchPlugins', () => {
});
});

describe('testPathPattern', () => {
describe('testPathPatterns', () => {
const initialOptions = {rootDir: '/root'};
const consoleLog = console.log;

Expand All @@ -1600,7 +1600,7 @@ describe('testPathPattern', () => {
it('defaults to empty', async () => {
const {options} = await normalize(initialOptions, {} as Config.Argv);

expect(options.testPathPattern).toBe('');
expect(options.testPathPatterns).toEqual([]);
});

const cliOptions = [
Expand All @@ -1613,22 +1613,22 @@ describe('testPathPattern', () => {
const argv = {[opt.property]: ['a/b']} as Config.Argv;
const {options} = await normalize(initialOptions, argv);

expect(options.testPathPattern).toBe('a/b');
expect(options.testPathPatterns).toEqual(['a/b']);
});

it('ignores invalid regular expressions and logs a warning', async () => {
const argv = {[opt.property]: ['a(']} as Config.Argv;
const {options} = await normalize(initialOptions, argv);

expect(options.testPathPattern).toBe('');
expect(options.testPathPatterns).toEqual([]);
expect(jest.mocked(console.log).mock.calls[0][0]).toMatchSnapshot();
});

it(`joins multiple ${opt.name} if set`, async () => {
const argv = {[opt.property]: ['a/b', 'c/d']} as Config.Argv;
const {options} = await normalize(initialOptions, argv);

expect(options.testPathPattern).toBe('a/b|c/d');
expect(options.testPathPatterns).toEqual(['a/b', 'c/d']);
});
});
}
Expand All @@ -1637,15 +1637,15 @@ describe('testPathPattern', () => {
const argv = {_: [1]} as Config.Argv;
const {options} = await normalize(initialOptions, argv);

expect(options.testPathPattern).toBe('1');
expect(options.testPathPatterns).toEqual(['1']);
});

it('joins multiple --testPathPatterns and <regexForTestFiles>', async () => {
const {options} = await normalize(initialOptions, {
_: ['a', 'b'],
testPathPattern: ['c', 'd'],
} as Config.Argv);
expect(options.testPathPattern).toBe('a|b|c|d');
expect(options.testPathPatterns).toEqual(['a', 'b', 'c', 'd']);
});

it('gives precedence to --all', async () => {
Expand Down

0 comments on commit 225b6fe

Please sign in to comment.