Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
fix: Use relative path for source to fix Jest coverage report
Browse files Browse the repository at this point in the history
Fixes #643
  • Loading branch information
Andrey Okonetchnikov committed Jan 8, 2018
1 parent 5672b0d commit 4204b81
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/jest/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const jestOptions = require('jest-cli/build/cli/args').options;
const { omit } = require('ramda');
const merge = require('deepmerge');
const loaderMerge = require('@neutrinojs/loader-merge');
const { isAbsolute, basename, join } = require('path');
const { isAbsolute, basename, join, relative } = require('path');
const { tmpdir } = require('os');
const { writeFileSync } = require('fs');

Expand Down Expand Up @@ -47,20 +47,24 @@ function normalizeJestOptions(opts, neutrino, usingBabel) {
...(opts.moduleFileExtensions || []),
...neutrino.config.resolve.extensions.values().map(e => e.replace('.', ''))
])];

const { extensions, source, tests, root } = neutrino.options
const collectCoverageFrom = [join(relative(root, source), `**/*.{${extensions.join(',')}}`)]

const testRegex = join(
basename(neutrino.options.tests),
`.*(_test|_spec|\\.test|\\.spec)\\.(${neutrino.options.extensions.join('|')})$`
basename(tests),
`.*(_test|_spec|\\.test|\\.spec)\\.(${extensions.join('|')})$`
);

return merge.all([
{
rootDir: neutrino.options.root,
rootDir: root,
moduleDirectories,
moduleFileExtensions,
moduleNameMapper,
bail: true,
coveragePathIgnorePatterns: [neutrino.options.node_modules],
collectCoverageFrom: [join(basename(neutrino.options.source), '**/*.js')],
collectCoverageFrom,
testRegex,
transform: { [transformNames]: require.resolve('./transformer') },
globals: {
Expand Down

0 comments on commit 4204b81

Please sign in to comment.