Skip to content

Commit

Permalink
Fix reporters: default config (jestjs#3562)
Browse files Browse the repository at this point in the history
  • Loading branch information
Met48 authored and cpojer committed May 16, 2017
1 parent 7a9c5cd commit de16e67
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,47 @@ Object {
}
`;

exports[`Custom Reporters Integration default reporters enabled 1`] = `
" PASS __tests__/add-test.js
Custom Reporters
✓ adds ok
"
`;

exports[`Custom Reporters Integration default reporters enabled 2`] = `
"Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: <<REPLACED>>
Ran all test suites matching \\"add-test.js\\".
"
`;
exports[`Custom Reporters Integration default reporters enabled 3`] = `
Object {
"onRunComplete": Object {
"called": true,
"numFailedTests": 0,
"numPassedTests": 1,
"numTotalTests": 1,
},
"onRunStart": Object {
"called": true,
"options": "object",
},
"onTestResult": Object {
"called": true,
"times": 1,
},
"onTestStart": Object {
"called": true,
"path": false,
},
"options": Object {},
}
`;
exports[`Custom Reporters Integration invalid format for adding reporters 1`] = `
"● Reporter Validation Error:
Expand Down
19 changes: 19 additions & 0 deletions integration_tests/__tests__/custom-reporters-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'use strict';

const skipOnWindows = require('skipOnWindows');
const {extractSummary} = require('../utils');
const runJest = require('../runJest');

describe('Custom Reporters Integration', () => {
Expand Down Expand Up @@ -58,6 +59,24 @@ describe('Custom Reporters Integration', () => {
expect(stderr).toMatchSnapshot();
});

test('default reporters enabled', () => {
const {stderr, stdout, status} = runJest('custom_reporters', [
'--config',
JSON.stringify({
reporters: ['default', '<rootDir>/reporters/TestReporter.js'],
}),
'add-test.js',
]);

const {summary, rest} = extractSummary(stderr);
const parsedJSON = JSON.parse(stdout);

expect(status).toBe(0);
expect(rest).toMatchSnapshot();
expect(summary).toMatchSnapshot();
expect(parsedJSON).toMatchSnapshot();
});

test('TestReporter with all tests passing', () => {
const {stdout, status, stderr} = runJest('custom_reporters', [
'add-test.js',
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/src/TestRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class TestRunner {

_addCustomReporters(reporters: Array<ReporterConfig>) {
const customReporters = reporters.filter(
reporter => reporter !== 'default',
reporterConfig => reporterConfig[0] !== 'default',
);

customReporters.forEach((reporter, index) => {
Expand Down

0 comments on commit de16e67

Please sign in to comment.