Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*~
/examples/*/node_modules/

/.idea
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SimenB we care to remove this or just leave it alone?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got it in my global gitignore. doesn't hurt, though?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't hurt. People have opinions on the topic (local vs global gitignore), but it's not a big deal to me too so meh 🤷‍♂️ .


/integration-tests/*/node_modules
/integration-tests/transform/*/coverage
/integration-tests/transform/*/node_modules
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* `[docs]` Add documentation for interactive snapshot mode ([#5291](https://github.com/facebook/jest/pull/5291))
* `[jest-editor-support]` Add watchAll flag ([#5523](https://github.com/facebook/jest/pull/5523))

### Chore & Maintenance

* `[jest-config]` Allow `<rootDir>` to be used with `collectCoverageFrom` ([#5524](https://github.com/facebook/jest/pull/5524))

## jest 22.2.2

### Fixes
Expand Down
25 changes: 25 additions & 0 deletions packages/jest-config/src/__tests__/normalize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,31 @@ describe('collectCoverageOnlyFrom', () => {
});
});

describe('collectCoverageFrom', () => {
it('substitutes <rootDir> tokens', () => {
const barBaz = 'bar/baz';
const quxQuux = 'qux/quux/';
const notQuxQuux = `!${quxQuux}`;

const {options} = normalize(
{
collectCoverageFrom: [
barBaz,
notQuxQuux,
`<rootDir>/${barBaz}`,
`!<rootDir>/${quxQuux}`,
],
rootDir: '/root/path/foo/',
},
{},
);

const expected = [barBaz, notQuxQuux, barBaz, notQuxQuux];

expect(options.collectCoverageFrom).toEqual(expected);
});
});

function testPathArray(key) {
it('normalizes all paths relative to rootDir', () => {
const {options} = normalize(
Expand Down
6 changes: 6 additions & 0 deletions packages/jest-config/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ const normalizeCollectCoverageFrom = (options: InitialOptions, key: string) => {
value = options[key];
}

if (value) {
value = value.map(filePath => {
return filePath.replace(/^(!?)(<rootDir>\/)(.*)/, '$1$3');
});
}

return value;
};

Expand Down