Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "reporters: ['default']" config #3562

Merged
merged 1 commit into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uuu, too bad Flow can't catch comparisons like that :/

);

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