Skip to content

Commit

Permalink
Add a trailing slash to the root pattern (#5464)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjesun authored Feb 5, 2018
1 parent a24204a commit af09be8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions packages/jest-cli/src/__tests__/search_source.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,5 +463,24 @@ describe('SearchSource', () => {
path.join(rootDir, '__testtests__', 'test.jsx'),
]);
});

it('does not mistake roots folders with prefix names', async () => {
const config = normalize(
{
name,
rootDir: '.',
roots: ['/foo/bar/prefix'],
},
{},
).options;

searchSource = new SearchSource(
await Runtime.createContext(config, {maxWorkers}),
);

const input = ['/foo/bar/prefix-suffix/__tests__/my-test.test.js'];
const data = searchSource.findTestsByPaths(input);
expect(data.tests).toEqual([]);
});
});
});
2 changes: 1 addition & 1 deletion packages/jest-cli/src/search_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class SearchSource {
const {config} = context;
this._context = context;
this._rootPattern = new RegExp(
config.roots.map(dir => escapePathForRegex(dir)).join('|'),
config.roots.map(dir => escapePathForRegex(dir + path.sep)).join('|'),
);

const ignorePattern = config.testPathIgnorePatterns;
Expand Down

0 comments on commit af09be8

Please sign in to comment.