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

Commit

Permalink
Use source directory for jest code coverage (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliperelman authored Oct 24, 2017
1 parent cec00f8 commit 1f09c91
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/neutrino-preset-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('neutrino-middleware-loader-merge');
const { isAbsolute, join } = require('path');
const { isAbsolute, basename, join } = require('path');
const { tmpdir } = require('os');
const { writeFileSync } = require('fs');

Expand Down Expand Up @@ -47,12 +47,14 @@ function normalizeJestOptions(opts, neutrino) {

return merge.all([
{
rootDir: neutrino.options.root,
moduleDirectories,
moduleFileExtensions,
moduleNameMapper,
bail: true,
roots: [neutrino.options.tests],
testRegex: '(_test|_spec|\\.test|\\.spec)\\.jsx?$',
coveragePathIgnorePatterns: [neutrino.options.node_modules],
collectCoverageFrom: [join(basename(neutrino.options.source), '**/*.js')],
testRegex: join(basename(neutrino.options.tests), '.*(_test|_spec|\\.test|\\.spec)\\.jsx?$'),
transform: { [jsNames]: require.resolve('./transformer') },
globals: {
BABEL_OPTIONS: omit(
Expand Down Expand Up @@ -114,7 +116,7 @@ module.exports = (neutrino, opts = {}) => {

writeFileSync(configFile, `${JSON.stringify(options, null, 2)}\n`);

jest.runCLI(cliOptions, options.roots, result =>
jest.runCLI(cliOptions, options.roots || [options.rootDir], result =>
(result.numFailedTests || result.numFailedTestSuites ?
reject() :
resolve()));
Expand Down

0 comments on commit 1f09c91

Please sign in to comment.