Skip to content

Commit

Permalink
Parallel coverage (resolve conflicts)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronabramov committed Apr 28, 2017
1 parent e6c979f commit 813cdc9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/jest-cli/src/TestRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class TestRunner {
} else {
const exit = () => process.exit(1);
this._dispatcher
.onRunComplete(contexts, this._config, aggregatedResults)
.onRunComplete(contexts, this._globalConfig, aggregatedResults)
.then(exit)
.catch(exit);
}
Expand Down
14 changes: 10 additions & 4 deletions packages/jest-cli/src/reporters/CoverageWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
*/
'use strict';

import type {Config, Path} from 'types/Config';
import type {GlobalConfig, ProjectConfig, Path} from 'types/Config';
import type {SerializableError} from 'types/TestResult';

const fs = require('fs');
const generateEmptyCoverage = require('../generateEmptyCoverage');

type CoverageWorkerData = {|
config: Config,
globalConfig: GlobalConfig,
config: ProjectConfig,
untestedFilePath: Path,
|};

Expand All @@ -43,12 +44,17 @@ process.on('uncaughtException', err => {
});

module.exports = (
{config, untestedFilePath}: CoverageWorkerData,
{globalConfig, config, untestedFilePath}: CoverageWorkerData,
callback: WorkerCallback,
) => {
try {
const source = fs.readFileSync(untestedFilePath).toString();
const result = generateEmptyCoverage(source, untestedFilePath, config);
const result = generateEmptyCoverage(
source,
untestedFilePath,
globalConfig,
config,
);
callback(null, result);
} catch (e) {
callback(formatCoverageError(e, untestedFilePath), undefined);
Expand Down
12 changes: 9 additions & 3 deletions packages/jest-cli/src/reporters/__tests__/CoverageWorker-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ jest.mock('fs').mock('../../generateEmptyCoverage');
const fs = require('fs');
const generateEmptyCoverage = require('../../generateEmptyCoverage');

const config = {collectCoverage: true};
const globalConfig = {collectCoverage: true};
const config = {};
const worker = require('../CoverageWorker');
const workerOptions = {config, untestedFilePath: 'asdf'};
const workerOptions = {config, globalConfig, untestedFilePath: 'asdf'};

describe('CoverageWorker', () => {
it('resolves to the result of generateEmptyCoverage upon success', () => {
Expand All @@ -24,7 +25,12 @@ describe('CoverageWorker', () => {
generateEmptyCoverage.mockImplementation(() => 42);
return new Promise(resolve => {
worker(workerOptions, (err, result) => {
expect(generateEmptyCoverage).toBeCalledWith(validJS, 'asdf', config);
expect(generateEmptyCoverage).toBeCalledWith(
validJS,
'asdf',
globalConfig,
config,
);
expect(result).toEqual(42);
resolve();
});
Expand Down

0 comments on commit 813cdc9

Please sign in to comment.