From 23e368724b38167df1af88ffc5ba8854ae3de9e5 Mon Sep 17 00:00:00 2001 From: Andrew Sutton Date: Fri, 12 May 2017 13:22:51 -0400 Subject: [PATCH] Fix reporters: default config --- .../custom-reporters-test.js.snap | 41 +++++++++++++++++++ .../__tests__/custom-reporters-test.js | 19 +++++++++ packages/jest-cli/src/TestRunner.js | 2 +- 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap b/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap index 895c0c20d57b..e47fd6013df6 100644 --- a/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap +++ b/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap @@ -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: <> +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: diff --git a/integration_tests/__tests__/custom-reporters-test.js b/integration_tests/__tests__/custom-reporters-test.js index 36750a432a45..2e57e3301161 100644 --- a/integration_tests/__tests__/custom-reporters-test.js +++ b/integration_tests/__tests__/custom-reporters-test.js @@ -8,6 +8,7 @@ 'use strict'; const skipOnWindows = require('skipOnWindows'); +const {extractSummary} = require('../utils'); const runJest = require('../runJest'); describe('Custom Reporters Integration', () => { @@ -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', '/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', diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index 6e259edc05bd..7e36cddb33e4 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -329,7 +329,7 @@ class TestRunner { _addCustomReporters(reporters: Array) { const customReporters = reporters.filter( - reporter => reporter !== 'default', + reporterConfig => reporterConfig[0] !== 'default', ); customReporters.forEach((reporter, index) => {