Skip to content

Commit

Permalink
Replace <rootDir> in testMatch and moduleDirectories (#3538)
Browse files Browse the repository at this point in the history
  • Loading branch information
thymikee authored and cpojer committed May 10, 2017
1 parent 0717c53 commit 12321fd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
35 changes: 35 additions & 0 deletions packages/jest-config/src/__tests__/normalize-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,41 @@ describe('testMatch', () => {
);
}).toThrowErrorMatchingSnapshot();
});

it('normalizes testMatch', () => {
const {options} = normalize(
{
rootDir: '/root',
testMatch: ['<rootDir>/**/*.js'],
},
{},
);

expect(options.testMatch).toEqual(['/root/**/*.js']);
});
});

describe('moduleDirectories', () => {
it('defaults to node_modules', () => {
const {options} = normalize({rootDir: '/root'}, {});

expect(options.moduleDirectories).toEqual(['node_modules']);
});

it('normalizes moduleDirectories', () => {
const {options} = normalize(
{
moduleDirectories: ['<rootDir>/src', '<rootDir>/node_modules'],
rootDir: '/root',
},
{},
);

expect(options.moduleDirectories).toEqual([
'/root/src',
'/root/node_modules',
]);
});
});

describe('preset', () => {
Expand Down
6 changes: 4 additions & 2 deletions packages/jest-config/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ function normalize(options: InitialOptions, argv: Argv) {
);
value = list;
break;
case 'moduleDirectories':
case 'testMatch':
value = _replaceRootDirTags(options.rootDir, options[key]);
break;
case 'automock':
case 'bail':
case 'browser':
Expand All @@ -409,7 +413,6 @@ function normalize(options: InitialOptions, argv: Argv) {
case 'globals':
case 'logHeapUsage':
case 'mapCoverage':
case 'moduleDirectories':
case 'moduleFileExtensions':
case 'name':
case 'noStackTrace':
Expand All @@ -421,7 +424,6 @@ function normalize(options: InitialOptions, argv: Argv) {
case 'rootDir':
case 'silent':
case 'testEnvironment':
case 'testMatch':
case 'testNamePattern':
case 'testRegex':
case 'testURL':
Expand Down

0 comments on commit 12321fd

Please sign in to comment.