Skip to content

Commit

Permalink
adds spec for reporter creation
Browse files Browse the repository at this point in the history
  • Loading branch information
flovilmart committed Feb 15, 2020
1 parent d8be437 commit 7889e51
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/jest-reporters/src/__tests__/coverage_reporter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jest
let libCoverage;
let libSourceMaps;
let CoverageReporter;
let istanbulReports;

import path from 'path';
import mock from 'mock-fs';
Expand All @@ -28,6 +29,7 @@ beforeEach(() => {
CoverageReporter = require('../coverage_reporter').default;
libCoverage = require('istanbul-lib-coverage');
libSourceMaps = require('istanbul-lib-source-maps');
istanbulReports = require('istanbul-reports');

const fileTree = {};
fileTree[process.cwd() + '/path-test-files'] = {
Expand Down Expand Up @@ -417,4 +419,23 @@ describe('onRunComplete', () => {
expect(testReporter.getLastError()).toBeUndefined();
});
});

test(`that it passes custom options when creating reporters`, () => {
const testReporter = new CoverageReporter({
coverageReporters: ['json', ['lcov', {maxCols: 10, projectRoot: './'}]],
});
testReporter.log = jest.fn();
return testReporter
.onRunComplete(new Set(), {}, mockAggResults)
.then(() => {
expect(istanbulReports.create).toHaveBeenCalledWith('json', {
maxCols: Infinity,
});
expect(istanbulReports.create).toHaveBeenCalledWith('lcov', {
maxCols: Infinity,
projectRoot: './',
});
expect(testReporter.getLastError()).toBeUndefined();
});
});
});

0 comments on commit 7889e51

Please sign in to comment.