From 98d01b5845f91babf5ab535859a49cbcec2d0ca6 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sat, 4 Mar 2017 02:29:33 +0500 Subject: [PATCH 01/59] add custom reporters option in TestRunner --- .vscode/settings.json | 4 +- packages/jest-cli/src/TestRunner.js | 59 +++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 7e62645bd9fe..7bdc4685281f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,7 @@ "jest.pathToJest": "npm run jest --", "editor.rulers": [ 80 - ] +], +"eslint.enable": true, +"javascript.validate.enable": false } diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index 25398af4c7ee..8e3f34859302 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -396,6 +396,65 @@ class TestRunner { if (config.notify) { this.addReporter(new NotifyReporter(this._startRun)); } + + if (Array.isArray(config.reporters)) { + this._addCustomReporters(config.reporters) + } else { + throw new Error( + `Unexpected value found for reporters + Expected to get an array of reporters, got: ${reporters}` + ); + } + } + + /** + * Add Custom reporters to Jest + * Custom reporters can be added to Jest using the reporters option in Jest + * Config. The format for adding a custom reporter is following: + * + * Format for the custom reporters + * + * "reporters": [ + * ["reporterPath/packageName", { option1: 'fasklj' }], + * // Format if we want to specify options + * + * "reporterName" + * // Format if we don't want to specify any options + * ] + */ + _addCustomReporters(reporters: Array) { + let reporterPath, reporterConfig; + + reporters.forEach(entry => { + if (Array.isArray(entry)) { + [reporterPath, reporterConfig] = entry; + } else { + if (typeof entry !== 'string') { + throw new Error(` + Unexpected custom reporter configuration. + Expected to get either a path string or an array of [path, confg] + got: ${entry} + `); + } + + reporterPath = entry; + } + + try { + const reporter = require(reporterPath); + this.addReporter(new reporter(reporterConfig || {})); + } catch (error) { + console.error(` + Failed to set up reporter: + ${JSON.stringify(reporterPath)} + Config: + ${JSON.stringify(reporterConfig)} + `); + + throw error; + } + }); + } } _bailIfNeeded(aggregatedResults: AggregatedResult, watcher: TestWatcher) { From 1215c0bfc5d7759c4a550b3c9da70435f871d7a8 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sat, 4 Mar 2017 06:54:57 +0500 Subject: [PATCH 02/59] add reporters option in jest-cli config --- packages/jest-cli/src/TestRunner.js | 72 +++++++++++++-------------- packages/jest-config/src/normalize.js | 3 ++ 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index 8e3f34859302..9e376d8e36d9 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -379,6 +379,10 @@ class TestRunner { _setupReporters() { const config = this._config; + if (config.reporters) { + return this._addCustomReporters(config.reporters); + } + this.addReporter( config.verbose ? new VerboseReporter(config) @@ -397,14 +401,7 @@ class TestRunner { this.addReporter(new NotifyReporter(this._startRun)); } - if (Array.isArray(config.reporters)) { - this._addCustomReporters(config.reporters) - } else { - throw new Error( - `Unexpected value found for reporters - Expected to get an array of reporters, got: ${reporters}` - ); - } + return undefined; } /** @@ -422,39 +419,38 @@ class TestRunner { * // Format if we don't want to specify any options * ] */ - _addCustomReporters(reporters: Array) { - let reporterPath, reporterConfig; - - reporters.forEach(entry => { - if (Array.isArray(entry)) { - [reporterPath, reporterConfig] = entry; - } else { - if (typeof entry !== 'string') { - throw new Error(` - Unexpected custom reporter configuration. - Expected to get either a path string or an array of [path, confg] - got: ${entry} - `); - } - - reporterPath = entry; - } + _addCustomReporters(reporters: any) { + let reporterPath, reporterConfig; - try { - const reporter = require(reporterPath); - this.addReporter(new reporter(reporterConfig || {})); - } catch (error) { - console.error(` - Failed to set up reporter: - ${JSON.stringify(reporterPath)} - Config: - ${JSON.stringify(reporterConfig)} + reporters.forEach(entry => { + if (Array.isArray(entry)) { + [reporterPath, reporterConfig] = entry; + } else { + if (typeof entry !== 'string') { + throw new Error(` + Unexpected custom reporter configuration. + Expected to get either a path string or an array of [path, confg] + got: ${JSON.stringify(entry)} `); - - throw error; } - }); - } + + reporterPath = entry; + } + + try { + const reporter = require(reporterPath); + this.addReporter(new reporter(reporterConfig || {})); + } catch (error) { + console.error(` + Failed to set up reporter: + ${JSON.stringify(reporterPath)} + Config: + ${JSON.stringify(reporterConfig)} + `); + + throw error; + } + }); } _bailIfNeeded(aggregatedResults: AggregatedResult, watcher: TestWatcher) { diff --git a/packages/jest-config/src/normalize.js b/packages/jest-config/src/normalize.js index ecc269dd28ad..f97ddd191f1a 100644 --- a/packages/jest-config/src/normalize.js +++ b/packages/jest-config/src/normalize.js @@ -354,6 +354,9 @@ function normalize(config: InitialConfig, argv: Object = {}) { case 'persistModuleRegistryBetweenSpecs': case 'preset': case 'replname': + case 'reporters': + value = _replaceRootDirTags(config.rootDir, config[key]); + break; case 'resetMocks': case 'resetModules': case 'rootDir': From b3196ac5f2fae5efcb58c8f051c65fece7b20da5 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sat, 4 Mar 2017 06:55:40 +0500 Subject: [PATCH 03/59] add flowtype for reporters option --- types/Config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/Config.js b/types/Config.js index 05805bc3488f..9dda4ad91593 100644 --- a/types/Config.js +++ b/types/Config.js @@ -87,6 +87,7 @@ export type Config = {| noStackTrace: boolean, notify: boolean, preset: ?string, + reporters: Array>, resetMocks: boolean, resetModules: boolean, rootDir: Path, @@ -132,6 +133,7 @@ export type InitialConfig = {| forceExit?: boolean, globals?: ConfigGlobals, haste?: HasteConfig, + reporters?: Array>, logHeapUsage?: boolean, logTransformErrors?: ?boolean, moduleDirectories?: Array, From 44f6550989c52599ef5b055259d87d6c34bb82e6 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sat, 4 Mar 2017 10:59:30 +0500 Subject: [PATCH 04/59] add key for reporters in validConfig --- packages/jest-config/src/validConfig.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/jest-config/src/validConfig.js b/packages/jest-config/src/validConfig.js index 27632e2c9205..2166f51ba51a 100644 --- a/packages/jest-config/src/validConfig.js +++ b/packages/jest-config/src/validConfig.js @@ -57,6 +57,9 @@ module.exports = ({ noStackTrace: false, notify: false, preset: 'react-native', + reporters: [ + ['./here-it-goes.js', {option1: true}] + ], resetMocks: false, resetModules: false, rootDir: '/', From aa548c9c4137bea062b59ab6cbaa46928e3d107d Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sun, 5 Mar 2017 05:12:46 +0500 Subject: [PATCH 05/59] add noDefaultReporters option noDefaultReporters option let's user turn off all the reporters set by default --- packages/jest-cli/src/TestRunner.js | 7 +++++++ packages/jest-config/src/normalize.js | 1 + packages/jest-config/src/validConfig.js | 1 + types/Config.js | 2 ++ 4 files changed, 11 insertions(+) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index 9e376d8e36d9..bdbd653e0a37 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -383,6 +383,13 @@ class TestRunner { return this._addCustomReporters(config.reporters); } + // if config.noDefaultReporters is true + // the function exits sooner, and no default reporters + // are added + if (config.noDefaultReporters) { + return false; + } + this.addReporter( config.verbose ? new VerboseReporter(config) diff --git a/packages/jest-config/src/normalize.js b/packages/jest-config/src/normalize.js index f97ddd191f1a..1073da0ddddb 100644 --- a/packages/jest-config/src/normalize.js +++ b/packages/jest-config/src/normalize.js @@ -349,6 +349,7 @@ function normalize(config: InitialConfig, argv: Object = {}) { case 'moduleLoader': case 'modulePaths': case 'name': + case 'noDefaultReporters': case 'noStackTrace': case 'notify': case 'persistModuleRegistryBetweenSpecs': diff --git a/packages/jest-config/src/validConfig.js b/packages/jest-config/src/validConfig.js index 2166f51ba51a..dd9bff82cee8 100644 --- a/packages/jest-config/src/validConfig.js +++ b/packages/jest-config/src/validConfig.js @@ -54,6 +54,7 @@ module.exports = ({ modulePathIgnorePatterns: ['/build/'], modulePaths: ['/shared/vendor/modules'], name: 'string', + noDefaultReporters: false, noStackTrace: false, notify: false, preset: 'react-native', diff --git a/types/Config.js b/types/Config.js index 9dda4ad91593..09c5467f5efd 100644 --- a/types/Config.js +++ b/types/Config.js @@ -84,6 +84,7 @@ export type Config = {| modulePathIgnorePatterns: Array, modulePaths: Array, name: string, + noDefaultReporters: boolean, noStackTrace: boolean, notify: boolean, preset: ?string, @@ -144,6 +145,7 @@ export type InitialConfig = {| modulePathIgnorePatterns?: Array, modulePaths?: Array, name?: string, + noDefaultReporters?: boolean, noStackTrace?: boolean, notify?: boolean, preprocessorIgnorePatterns?: Array, From 268a64015be859ec09f3f12849d3a6c46242cc45 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sun, 5 Mar 2017 05:14:11 +0500 Subject: [PATCH 06/59] Lint --- packages/jest-config/src/validConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest-config/src/validConfig.js b/packages/jest-config/src/validConfig.js index dd9bff82cee8..da4ea2120db9 100644 --- a/packages/jest-config/src/validConfig.js +++ b/packages/jest-config/src/validConfig.js @@ -59,7 +59,7 @@ module.exports = ({ notify: false, preset: 'react-native', reporters: [ - ['./here-it-goes.js', {option1: true}] + ['./here-it-goes.js', {option1: true}], ], resetMocks: false, resetModules: false, From e79ae0cd78a352ff0adb385c7080405b6fddfec4 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sun, 5 Mar 2017 07:41:38 +0500 Subject: [PATCH 07/59] add unit tests for _addCustomReporters --- packages/jest-cli/src/TestRunner.js | 4 +- .../jest-cli/src/__tests__/TestRunner-test.js | 73 +++++++++++++++++++ 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index bdbd653e0a37..61941132639f 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -414,9 +414,7 @@ class TestRunner { /** * Add Custom reporters to Jest * Custom reporters can be added to Jest using the reporters option in Jest - * Config. The format for adding a custom reporter is following: - * - * Format for the custom reporters + * Config. The format for adding a custom reporter is following * * "reporters": [ * ["reporterPath/packageName", { option1: 'fasklj' }], diff --git a/packages/jest-cli/src/__tests__/TestRunner-test.js b/packages/jest-cli/src/__tests__/TestRunner-test.js index e91862c3802e..5e0e2e817df3 100644 --- a/packages/jest-cli/src/__tests__/TestRunner-test.js +++ b/packages/jest-cli/src/__tests__/TestRunner-test.js @@ -38,6 +38,79 @@ test('.addReporter() .removeReporter()', () => { expect(runner._dispatcher._reporters).not.toContain(reporter); }); +// Checking for the method _addCustomReporters +// Custom reporters used here are the reporters within the package +// No extra reporters are included to be used +describe('_addCustomReporters', () => { + // Paths for the given reporters + const SUMMARY_REPORTER_PATH = './reporters/SummaryReporter.js'; + const VERBOSE_REPORTER_PATH = './reporters/VerboseReporter.js'; + const DEFAULT_REPORTER_PATH = './reporters/DefaultReporter.js'; + + // Requiring constructors of the given reporters + // to check against the reporters added + const summaryReporter = require('.' + SUMMARY_REPORTER_PATH); + const verboseReporter = require('.' + VERBOSE_REPORTER_PATH); + const defaultReporter = require('.' + DEFAULT_REPORTER_PATH); + + let runner; + + beforeEach(() => { + runner = new TestRunner({}, {}, {}); + + // Removing all the reporters we previously have in the + // Dispatcher. Helps in removing inconsistencies in Tests. + runner._dispatcher._reporters = []; + }); + + it('adds reporter using 2D Array format', () => { + const reporters = [ + [SUMMARY_REPORTER_PATH, {}], + ]; + + expect(runner._dispatcher._reporters).toHaveLength(0); + expect(runner._dispatcher._reporters[0]).toBeUndefined(); + + runner._addCustomReporters(reporters); + + expect(runner._dispatcher._reporters).toHaveLength(1); + expect(runner._dispatcher._reporters.pop()).toBeInstanceOf(summaryReporter); + }); + + it('adds reporter using 2D syntax with no configuration object', () => { + const reporters = [ + [SUMMARY_REPORTER_PATH], + ]; + + runner._addCustomReporters(reporters); + + expect(runner._dispatcher._reporters).toHaveLength(1); + expect(runner._dispatcher._reporters.pop()).toBeInstanceOf(SummaryReporter); + }); + + it('adds reporter using string syntax (no custom configuration)', () => { + const reporters = [ + SUMMARY_REPORTER_PATH, + ]; + runner._addCustomReporters(reporters); + + expect(runner._dispatcher._reporters).toHaveLength(1); + expect(runner._dispatcher._reporters.pop()).toBeInstanceOf(summaryReporter); + }); + + it('adds two reporters with variable format', () => { + const reporters = [ + VERBOSE_REPORTER_PATH, + [DEFAULT_REPORTER_PATH, {}], + ]; + runner._addCustomReporters(reporters); + + expect(runner._dispatcher._reporters).toHaveLength(2); + + expect(runner._dispatcher._reporters[0]).toBeInstanceOf(verboseReporter); + expect(runner._dispatcher._reporters[1]).toBeInstanceOf(defaultReporter); + }); +}); describe('_createInBandTestRun()', () => { test('injects the rawModuleMap to each the worker in watch mode', () => { From 2ee53ce66a30d9de619cd49a16521eaafdaf8c63 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 6 Mar 2017 09:30:57 +0500 Subject: [PATCH 08/59] separate default reporters in method in TestRunner --- packages/jest-cli/src/TestRunner.js | 35 +++++++++++++++++------------ 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index 61941132639f..8265830fe49c 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -380,22 +380,16 @@ class TestRunner { const config = this._config; if (config.reporters) { - return this._addCustomReporters(config.reporters); + this._addCustomReporters(config.reporters); } - // if config.noDefaultReporters is true - // the function exits sooner, and no default reporters - // are added - if (config.noDefaultReporters) { - return false; + // Default Reporters are setup when + // noDefaultReporters is false, which is false by default + // and can be set to true in configuration. + if (!config.noDefaultReporters) { + this._setupDefaultReporters(); } - this.addReporter( - config.verbose - ? new VerboseReporter(config) - : new DefaultReporter(), - ); - if (config.collectCoverage) { // coverage reporter dependency graph is pretty big and we don't // want to require it if we're not in the `--coverage` mode @@ -403,12 +397,25 @@ class TestRunner { this.addReporter(new CoverageReporter()); } - this.addReporter(new SummaryReporter()); if (config.notify) { this.addReporter(new NotifyReporter(this._startRun)); } + } - return undefined; + /** + * _setupDefaultReporters + * Method for setting up the default reporters + */ + _setupDefaultReporters() { + const config = this._config; + + this.addReporter( + config.verbose + ? new VerboseReporter(config) + : new DefaultReporter() + ); + + this.addReporter(new SummaryReporter()); } /** From 073d6e9f60a904bf8a1b34a6e6e1e3c2594e5ee5 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 6 Mar 2017 09:31:46 +0500 Subject: [PATCH 09/59] add tests for errors which are thrown --- .../jest-cli/src/__tests__/TestRunner-test.js | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/packages/jest-cli/src/__tests__/TestRunner-test.js b/packages/jest-cli/src/__tests__/TestRunner-test.js index 5e0e2e817df3..8e3b4223e063 100644 --- a/packages/jest-cli/src/__tests__/TestRunner-test.js +++ b/packages/jest-cli/src/__tests__/TestRunner-test.js @@ -63,7 +63,7 @@ describe('_addCustomReporters', () => { runner._dispatcher._reporters = []; }); - it('adds reporter using 2D Array format', () => { + test('adds reporter using 2D Array format', () => { const reporters = [ [SUMMARY_REPORTER_PATH, {}], ]; @@ -77,7 +77,7 @@ describe('_addCustomReporters', () => { expect(runner._dispatcher._reporters.pop()).toBeInstanceOf(summaryReporter); }); - it('adds reporter using 2D syntax with no configuration object', () => { + test('adds reporter using 2D syntax with no configuration object', () => { const reporters = [ [SUMMARY_REPORTER_PATH], ]; @@ -88,17 +88,18 @@ describe('_addCustomReporters', () => { expect(runner._dispatcher._reporters.pop()).toBeInstanceOf(SummaryReporter); }); - it('adds reporter using string syntax (no custom configuration)', () => { + test('adds reporter using string syntax (no custom configuration)', () => { const reporters = [ SUMMARY_REPORTER_PATH, ]; + runner._addCustomReporters(reporters); expect(runner._dispatcher._reporters).toHaveLength(1); expect(runner._dispatcher._reporters.pop()).toBeInstanceOf(summaryReporter); }); - it('adds two reporters with variable format', () => { + test('adds two reporters with variable format', () => { const reporters = [ VERBOSE_REPORTER_PATH, [DEFAULT_REPORTER_PATH, {}], @@ -110,6 +111,26 @@ describe('_addCustomReporters', () => { expect(runner._dispatcher._reporters[0]).toBeInstanceOf(verboseReporter); expect(runner._dispatcher._reporters[1]).toBeInstanceOf(defaultReporter); }); + + test('throws on invalid file path', () => { + const reporters = [ + ['ohthisisnotgoingtobearealpath.sadfslj', {}], + ]; + + const addInvalidReporters = () => { + runner._addCustomReporters(reporters); + }; + + expect(addInvalidReporters).toThrow(); + expect(addInvalidReporters).toThrow(/Cannot find module/); + expect(runner._dispatcher._reporters).toHaveLength(0); + }); + + test('throws on invalid argument to reporter', () => { + expect(() => { + runner._addCustomReporters('This should be an array obviously'); + }).toThrow(); + }); }); describe('_createInBandTestRun()', () => { From 6a430de7aa68097f304cc77e73e63d283b1c160e Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 6 Mar 2017 09:53:30 +0500 Subject: [PATCH 10/59] add tests for .noDefaultReporters --- .../jest-cli/src/__tests__/TestRunner-test.js | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/jest-cli/src/__tests__/TestRunner-test.js b/packages/jest-cli/src/__tests__/TestRunner-test.js index 8e3b4223e063..752b90f03d0e 100644 --- a/packages/jest-cli/src/__tests__/TestRunner-test.js +++ b/packages/jest-cli/src/__tests__/TestRunner-test.js @@ -38,6 +38,25 @@ test('.addReporter() .removeReporter()', () => { expect(runner._dispatcher._reporters).not.toContain(reporter); }); +describe('noDefaultReporters option', () => { + let runner; + + test('does not add reporters if true', () => { + runner = new TestRunner({}, {noDefaultReporters: true}, {}); + expect(runner._dispatcher._reporters).toHaveLength(0); + }); + + test('adds reporters if undefined', () => { + runner = new TestRunner({}, {}, {}); + expect(runner._dispatcher._reporters).toHaveLength(2); + }); + + test('adds reporters if false', () => { + runner = new TestRunner({}, {noDefaultReporters: false}, {}); + expect(runner._dispatcher._reporters).toHaveLength(2); + }); +}); + // Checking for the method _addCustomReporters // Custom reporters used here are the reporters within the package // No extra reporters are included to be used @@ -56,11 +75,7 @@ describe('_addCustomReporters', () => { let runner; beforeEach(() => { - runner = new TestRunner({}, {}, {}); - - // Removing all the reporters we previously have in the - // Dispatcher. Helps in removing inconsistencies in Tests. - runner._dispatcher._reporters = []; + runner = new TestRunner({}, {noDefaultReporters: true}, {}); }); test('adds reporter using 2D Array format', () => { @@ -175,3 +190,4 @@ describe('_createInBandTestRun()', () => { }); }); }); + From 7cc7aea24b865f11e74242555b175849dffa7702 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Wed, 8 Mar 2017 15:41:15 +0500 Subject: [PATCH 11/59] modify Error thrown for _addCustomReporters --- packages/jest-cli/src/TestRunner.js | 32 +++++++++++-------- .../jest-cli/src/__tests__/TestRunner-test.js | 5 ++- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index 829f8277137b..56773a48448c 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -20,6 +20,10 @@ import type {RunnerContext} from 'types/Reporters'; import type BaseReporter from './reporters/BaseReporter'; const {formatExecError} = require('jest-message-util'); +const {getType} = require('jest-matcher-utils'); +const prettyFormat = require('pretty-format'); + + const fs = require('graceful-fs'); const getCacheFilePath = require('jest-haste-map').getCacheFilePath; const DefaultReporter = require('./reporters/DefaultReporter'); @@ -27,6 +31,7 @@ const NotifyReporter = require('./reporters/NotifyReporter'); const SummaryReporter = require('./reporters/SummaryReporter'); const VerboseReporter = require('./reporters/VerboseReporter'); const pify = require('pify'); +const chalk = require('chalk'); const runTest = require('./runTest'); const snapshot = require('jest-snapshot'); const throat = require('throat'); @@ -422,11 +427,13 @@ class TestRunner { [reporterPath, reporterConfig] = entry; } else { if (typeof entry !== 'string') { - throw new Error(` - Unexpected custom reporter configuration. - Expected to get either a path string or an array of [path, confg] - got: ${JSON.stringify(entry)} - `); + throw new Error( + 'Unexpected Custom Reporter Entry\n' + + 'Report Entry should be of type:\n' + + `\t\t ${chalk.bold(chalk.green('String / Array'))}\n` + + 'Received:\n' + + `\t\t ${chalk.bold(chalk.red(getType(entry)))}` + ) } reporterPath = entry; @@ -436,14 +443,13 @@ class TestRunner { const reporter = require(reporterPath); this.addReporter(new reporter(reporterConfig || {})); } catch (error) { - console.error(` - Failed to set up reporter: - ${JSON.stringify(reporterPath)} - Config: - ${JSON.stringify(reporterConfig)} - `); - - throw error; + throw new Error( + `Failed to set up reporter: \n` + + `Reporter Path:\n` + + `\t\t${prettyFormat(reporterPath)}` + + 'Reporter Configuration:\n' + + `\t\t${prettyFormat(reporterConfig)}` + ); } }); } diff --git a/packages/jest-cli/src/__tests__/TestRunner-test.js b/packages/jest-cli/src/__tests__/TestRunner-test.js index 752b90f03d0e..191f9b69cac5 100644 --- a/packages/jest-cli/src/__tests__/TestRunner-test.js +++ b/packages/jest-cli/src/__tests__/TestRunner-test.js @@ -132,12 +132,11 @@ describe('_addCustomReporters', () => { ['ohthisisnotgoingtobearealpath.sadfslj', {}], ]; - const addInvalidReporters = () => { + const addNonexistentReporters = () => { runner._addCustomReporters(reporters); }; - expect(addInvalidReporters).toThrow(); - expect(addInvalidReporters).toThrow(/Cannot find module/); + expect(addNonexistentReporters).toThrow(/Failed to set up reporter/); expect(runner._dispatcher._reporters).toHaveLength(0); }); From 138bec37b9a3f246892ff7b58de7ba8254e0cba6 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Wed, 8 Mar 2017 15:50:36 +0500 Subject: [PATCH 12/59] remove superfluous comment from TestRunner.js --- packages/jest-cli/src/TestRunner.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index 56773a48448c..d1c117d95456 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -369,11 +369,7 @@ class TestRunner { _setupReporters() { const config = this._config; - - - // Default Reporters are setup when - // noDefaultReporters is false, which is false by default - // and can be set to true in configuration. + if (!config.noDefaultReporters) { this._setupDefaultReporters(); } From 6da8dad9c2a0b186af5c02b62686e031f3861fe9 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sat, 1 Apr 2017 05:03:26 +0500 Subject: [PATCH 13/59] remove reporter tests from TestRunner-test.js --- packages/jest-cli/src/TestRunner.js | 125 ++++++++++++------ .../jest-cli/src/__tests__/TestRunner-test.js | 109 --------------- 2 files changed, 88 insertions(+), 146 deletions(-) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index d1c117d95456..a8f7900e3484 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -14,7 +14,10 @@ import type { SerializableError as TestError, TestResult, } from 'types/TestResult'; -import type {Config, Path} from 'types/Config'; +import type { + Config, Path, + ReporterConfig, +} from 'types/Config'; import type {HasteContext, HasteFS} from 'types/HasteMap'; import type {RunnerContext} from 'types/Reporters'; import type BaseReporter from './reporters/BaseReporter'; @@ -22,6 +25,7 @@ import type BaseReporter from './reporters/BaseReporter'; const {formatExecError} = require('jest-message-util'); const {getType} = require('jest-matcher-utils'); const prettyFormat = require('pretty-format'); +const assert = require('assert'); const fs = require('graceful-fs'); @@ -38,6 +42,8 @@ const throat = require('throat'); const workerFarm = require('worker-farm'); const TestWatcher = require('./TestWatcher'); +const DEFAULT_REPORTER_LABEL = 'default'; + const FAIL = 0; const SLOW_TEST_TIME = 3000; const SUCCESS = 1; @@ -55,7 +61,6 @@ type Options = {| |}; type OnRunFailure = (path: string, err: TestError) => void; - type OnTestResult = (path: string, result: TestResult) => void; const TEST_WORKER_PATH = require.resolve('./TestWorker'); @@ -367,11 +372,33 @@ class TestRunner { return Promise.race([runAllTests, onInterrupt]).then(cleanup, cleanup); } + /** + * _checkDefaultReporters + * Checks if we are going to add the default reporters or not + */ + _checkDefaultReporters(reporters: ReporterConfig): boolean { + return reporters.indexOf(DEFAULT_REPORTER_LABEL) !== -1; + } + _setupReporters() { const config = this._config; + const {reporters} = config; + let isDefault; - if (!config.noDefaultReporters) { - this._setupDefaultReporters(); + if (reporters && Array.isArray(reporters)) { + isDefault = this._checkDefaultReporters(reporters); + const customReporters = reporters.filter(reporter => { + return reporter !== DEFAULT_REPORTER_LABEL; + }); + this._addCustomReporters(customReporters); + } + + + /** + * Add Default Reporters in case if no reporters are added by default + */ + if (isDefault || !reporters) { + this._setupDefaultReporters(config); } if (config.collectCoverage) { @@ -388,10 +415,10 @@ class TestRunner { /** * _setupDefaultReporters - * Method for setting up the default reporters + * + * @param {config} Object Config object containing all the options */ - _setupDefaultReporters() { - const config = this._config; + _setupDefaultReporters(config: Config) { this.addReporter( config.verbose @@ -403,49 +430,73 @@ class TestRunner { } /** - * Add Custom reporters to Jest + * gets the props for the given custom reporter, whether reporter is + * defined as a String or an Array to make things simple for us. + */ + _getReporterProps(reporter: any): Object { + const props = {}; + let reporterPath, reporterConfig; + + if (typeof reporter === 'string') { + reporterPath = reporter; + } else if (Array.isArray(reporter)) { + [reporterPath, reporterConfig] = reporter; + } + + props['reporterPath'] = reporterPath; + props['reporterConfig'] = reporterConfig; + + return props; + } + + /** + * Adds Custom reporters to Jest * Custom reporters can be added to Jest using the reporters option in Jest * Config. The format for adding a custom reporter is following * * "reporters": [ * ["reporterPath/packageName", { option1: 'fasklj' }], * // Format if we want to specify options - * * "reporterName" * // Format if we don't want to specify any options * ] + * + * @private + * @param {ReporterConfig} reporters Array of reporters + * */ - _addCustomReporters(reporters: any) { - let reporterPath, reporterConfig; - - reporters.forEach(entry => { - if (Array.isArray(entry)) { - [reporterPath, reporterConfig] = entry; - } else { - if (typeof entry !== 'string') { - throw new Error( - 'Unexpected Custom Reporter Entry\n' + - 'Report Entry should be of type:\n' + - `\t\t ${chalk.bold(chalk.green('String / Array'))}\n` + - 'Received:\n' + - `\t\t ${chalk.bold(chalk.red(getType(entry)))}` - ) - } - - reporterPath = entry; - } - + _addCustomReporters(reporters: ReporterConfig) { + this._validateCustomReporters(reporters); + reporters.forEach(reporter => { try { - const reporter = require(reporterPath); - this.addReporter(new reporter(reporterConfig || {})); + const { + reporterPath, + reporterConfig = {}, + } = this._getReporterProps(reporter); + const Reporter = require(reporterPath); + this.addReporter(new Reporter(reporterConfig)); } catch (error) { - throw new Error( - `Failed to set up reporter: \n` + - `Reporter Path:\n` + - `\t\t${prettyFormat(reporterPath)}` + - 'Reporter Configuration:\n' + - `\t\t${prettyFormat(reporterConfig)}` + throw error; + } + }); + } + + /** + * Vaidates all the Custom Reporters and the format they are specified before + * adding them within the application + */ + _validateCustomReporters(customReporters: ReporterConfig) { + // Validate Custom Reporters here + customReporters.forEach(reporter => { + if (typeof reporter === 'string') { + return; + } else if (typeof Array.isArray(reporter)) { + const [reporterPath, reporterConfig] = reporter; + assert( + typeof reporterPath === 'string', 'reporterPath should be string' ); + } else { + throw new Error('reporter should be an array or a string'); } }); } diff --git a/packages/jest-cli/src/__tests__/TestRunner-test.js b/packages/jest-cli/src/__tests__/TestRunner-test.js index 191f9b69cac5..81f6c45a6a80 100644 --- a/packages/jest-cli/src/__tests__/TestRunner-test.js +++ b/packages/jest-cli/src/__tests__/TestRunner-test.js @@ -38,115 +38,6 @@ test('.addReporter() .removeReporter()', () => { expect(runner._dispatcher._reporters).not.toContain(reporter); }); -describe('noDefaultReporters option', () => { - let runner; - - test('does not add reporters if true', () => { - runner = new TestRunner({}, {noDefaultReporters: true}, {}); - expect(runner._dispatcher._reporters).toHaveLength(0); - }); - - test('adds reporters if undefined', () => { - runner = new TestRunner({}, {}, {}); - expect(runner._dispatcher._reporters).toHaveLength(2); - }); - - test('adds reporters if false', () => { - runner = new TestRunner({}, {noDefaultReporters: false}, {}); - expect(runner._dispatcher._reporters).toHaveLength(2); - }); -}); - -// Checking for the method _addCustomReporters -// Custom reporters used here are the reporters within the package -// No extra reporters are included to be used -describe('_addCustomReporters', () => { - // Paths for the given reporters - const SUMMARY_REPORTER_PATH = './reporters/SummaryReporter.js'; - const VERBOSE_REPORTER_PATH = './reporters/VerboseReporter.js'; - const DEFAULT_REPORTER_PATH = './reporters/DefaultReporter.js'; - - // Requiring constructors of the given reporters - // to check against the reporters added - const summaryReporter = require('.' + SUMMARY_REPORTER_PATH); - const verboseReporter = require('.' + VERBOSE_REPORTER_PATH); - const defaultReporter = require('.' + DEFAULT_REPORTER_PATH); - - let runner; - - beforeEach(() => { - runner = new TestRunner({}, {noDefaultReporters: true}, {}); - }); - - test('adds reporter using 2D Array format', () => { - const reporters = [ - [SUMMARY_REPORTER_PATH, {}], - ]; - - expect(runner._dispatcher._reporters).toHaveLength(0); - expect(runner._dispatcher._reporters[0]).toBeUndefined(); - - runner._addCustomReporters(reporters); - - expect(runner._dispatcher._reporters).toHaveLength(1); - expect(runner._dispatcher._reporters.pop()).toBeInstanceOf(summaryReporter); - }); - - test('adds reporter using 2D syntax with no configuration object', () => { - const reporters = [ - [SUMMARY_REPORTER_PATH], - ]; - - runner._addCustomReporters(reporters); - - expect(runner._dispatcher._reporters).toHaveLength(1); - expect(runner._dispatcher._reporters.pop()).toBeInstanceOf(SummaryReporter); - }); - - test('adds reporter using string syntax (no custom configuration)', () => { - const reporters = [ - SUMMARY_REPORTER_PATH, - ]; - - runner._addCustomReporters(reporters); - - expect(runner._dispatcher._reporters).toHaveLength(1); - expect(runner._dispatcher._reporters.pop()).toBeInstanceOf(summaryReporter); - }); - - test('adds two reporters with variable format', () => { - const reporters = [ - VERBOSE_REPORTER_PATH, - [DEFAULT_REPORTER_PATH, {}], - ]; - runner._addCustomReporters(reporters); - - expect(runner._dispatcher._reporters).toHaveLength(2); - - expect(runner._dispatcher._reporters[0]).toBeInstanceOf(verboseReporter); - expect(runner._dispatcher._reporters[1]).toBeInstanceOf(defaultReporter); - }); - - test('throws on invalid file path', () => { - const reporters = [ - ['ohthisisnotgoingtobearealpath.sadfslj', {}], - ]; - - const addNonexistentReporters = () => { - runner._addCustomReporters(reporters); - }; - - expect(addNonexistentReporters).toThrow(/Failed to set up reporter/); - expect(runner._dispatcher._reporters).toHaveLength(0); - }); - - test('throws on invalid argument to reporter', () => { - expect(() => { - runner._addCustomReporters('This should be an array obviously'); - }).toThrow(); - }); -}); - describe('_createInBandTestRun()', () => { test('injects the rawModuleMap to each the worker in watch mode', () => { const config = {watch: true}; From 352380b0312f18c9fe58eced992712b5a2ccfe3a Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sat, 1 Apr 2017 05:19:00 +0500 Subject: [PATCH 14/59] add new custom reporters format in TestRunner.js --- packages/jest-cli/src/TestRunner.js | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index a8f7900e3484..4869eaef3803 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -376,29 +376,21 @@ class TestRunner { * _checkDefaultReporters * Checks if we are going to add the default reporters or not */ - _checkDefaultReporters(reporters: ReporterConfig): boolean { - return reporters.indexOf(DEFAULT_REPORTER_LABEL) !== -1; + _addDefaultReporters(reporters?: ReporterConfig): boolean { + return !reporters || reporters.indexOf(DEFAULT_REPORTER_LABEL) !== -1; } _setupReporters() { const config = this._config; const {reporters} = config; - let isDefault; + const addDefault = this._addDefaultReporters(reporters); - if (reporters && Array.isArray(reporters)) { - isDefault = this._checkDefaultReporters(reporters); - const customReporters = reporters.filter(reporter => { - return reporter !== DEFAULT_REPORTER_LABEL; - }); - this._addCustomReporters(customReporters); + if (addDefault) { + this._setupDefaultReporters(config); } - - /** - * Add Default Reporters in case if no reporters are added by default - */ - if (isDefault || !reporters) { - this._setupDefaultReporters(config); + if (reporters && Array.isArray(reporters)) { + this._addCustomReporters(reporters); } if (config.collectCoverage) { @@ -419,7 +411,6 @@ class TestRunner { * @param {config} Object Config object containing all the options */ _setupDefaultReporters(config: Config) { - this.addReporter( config.verbose ? new VerboseReporter(config) @@ -467,7 +458,8 @@ class TestRunner { */ _addCustomReporters(reporters: ReporterConfig) { this._validateCustomReporters(reporters); - reporters.forEach(reporter => { + const customReporter = reporters.filter(reporter => reporter !== 'default'); + customReporter.forEach(reporter => { try { const { reporterPath, From 1a5ac39e8fa5f658439132648a6d13a351184bf6 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sat, 1 Apr 2017 05:28:19 +0500 Subject: [PATCH 15/59] update the format for adding customReporter --- packages/jest-config/src/normalize.js | 1 - packages/jest-config/src/validConfig.js | 5 +++-- types/Config.js | 11 +++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/jest-config/src/normalize.js b/packages/jest-config/src/normalize.js index d4e434fe3bf0..0b37de979f05 100644 --- a/packages/jest-config/src/normalize.js +++ b/packages/jest-config/src/normalize.js @@ -351,7 +351,6 @@ function normalize(config: InitialConfig, argv: Object = {}) { case 'moduleLoader': case 'modulePaths': case 'name': - case 'noDefaultReporters': case 'noStackTrace': case 'notify': case 'persistModuleRegistryBetweenSpecs': diff --git a/packages/jest-config/src/validConfig.js b/packages/jest-config/src/validConfig.js index 9f34b0b3cd3d..19c1585dd0b5 100644 --- a/packages/jest-config/src/validConfig.js +++ b/packages/jest-config/src/validConfig.js @@ -55,12 +55,13 @@ module.exports = ({ modulePathIgnorePatterns: ['/build/'], modulePaths: ['/shared/vendor/modules'], name: 'string', - noDefaultReporters: false, noStackTrace: false, notify: false, preset: 'react-native', reporters: [ - ['./here-it-goes.js', {option1: true}], + 'default', + 'custom-reporter-1', + ['custom-reporter-2', {configValue: true}], ], resetMocks: false, resetModules: false, diff --git a/types/Config.js b/types/Config.js index f335d23855db..1740605d749d 100644 --- a/types/Config.js +++ b/types/Config.js @@ -19,6 +19,11 @@ export type HasteConfig = {| providesModuleNodeModules: Array, |}; + +export type SimpleReporter = string; +export type ComplexReporter = [string, Object]; +export type ReporterConfig = Array; + export type ConfigGlobals = Object; export type DefaultConfig = {| @@ -86,11 +91,10 @@ export type Config = {| modulePathIgnorePatterns: Array, modulePaths: Array, name: string, - noDefaultReporters: boolean, noStackTrace: boolean, notify: boolean, preset: ?string, - reporters: Array>, + reporters: ReporterConfig, resetMocks: boolean, resetModules: boolean, resolver: ?Path, @@ -137,7 +141,7 @@ export type InitialConfig = {| forceExit?: boolean, globals?: ConfigGlobals, haste?: HasteConfig, - reporters?: Array>, + reporters?: ReporterConfig, logHeapUsage?: boolean, logTransformErrors?: ?boolean, mapCoverage?: boolean, @@ -149,7 +153,6 @@ export type InitialConfig = {| modulePathIgnorePatterns?: Array, modulePaths?: Array, name?: string, - noDefaultReporters?: boolean, noStackTrace?: boolean, notify?: boolean, preprocessorIgnorePatterns?: Array, From d067e596c8f84695618ce8fefa58d2380fafc04e Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sat, 1 Apr 2017 16:25:04 +0500 Subject: [PATCH 16/59] add descriptive validations for reporters --- packages/jest-cli/src/TestRunner.js | 46 +++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index 626cb866e4c3..ed82ac2908ab 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -22,7 +22,6 @@ import type {Test, Tests} from 'types/TestRunner'; import type BaseReporter from './reporters/BaseReporter'; const {formatExecError} = require('jest-message-util'); -const assert = require('assert'); const DefaultReporter = require('./reporters/DefaultReporter'); const NotifyReporter = require('./reporters/NotifyReporter'); @@ -45,6 +44,10 @@ class CancelRun extends Error { } } +class ReporterValidationError extends Error { + +} + type Options = {| maxWorkers: number, getTestSummary: () => string, @@ -76,7 +79,7 @@ class TestRunner { this._context = hasteContext; this._options = options; this._startRun = startRun; - this._setupReporters(); + this._setupReporters(config); } addReporter(reporter: BaseReporter) { @@ -283,8 +286,7 @@ class TestRunner { return !reporters || reporters.indexOf(DEFAULT_REPORTER_LABEL) !== -1; } - _setupReporters() { - const config = this._config; + _setupReporters(config: Config) { const {reporters} = config; const addDefault = this._addDefaultReporters(reporters); @@ -292,6 +294,7 @@ class TestRunner { this._setupDefaultReporters(config); } + if (reporters && Array.isArray(reporters)) { this._addCustomReporters(reporters); } @@ -380,18 +383,37 @@ class TestRunner { * Vaidates all the Custom Reporters and the format they are specified before * adding them within the application */ + _validateCustomReporters(customReporters: ReporterConfig) { // Validate Custom Reporters here - customReporters.forEach(reporter => { - if (typeof reporter === 'string') { - return; - } else if (typeof Array.isArray(reporter)) { + customReporters.forEach((reporter, index) => { + if (Array.isArray(reporter)) { const [reporterPath, reporterConfig] = reporter; - assert( - typeof reporterPath === 'string', 'reporterPath should be string' + if (typeof reporterPath !== 'string') { + throw new Error( + `Expected reporterPath for reporter at index ${index}` + + 'to be string\n' + + 'Got:\n' + + typeof reporter + ); + } + + if (reporterConfig && typeof reporterConfig !== 'object') { + throw new Error( + `Expected configuration for reporter at index ${index}\n` + + 'to be of type object\n' + + 'Got:\n' + + reporterConfig + ); + } + } else if (typeof reporter !== 'string') { + throw new Error( + `Unexpected Custom Reporter Configuration at index ${index}\n` + + 'Expected:\n' + + `array/string\n` + + 'Got:\n' + + typeof reporter ); - } else { - throw new Error('reporter should be an array or a string'); } }); } From 302b6724f4b9c330c9690a6677e2f7c3dd4d4238 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sat, 1 Apr 2017 16:25:41 +0500 Subject: [PATCH 17/59] add reporters attibute in normalize.js --- packages/jest-config/src/normalize.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/jest-config/src/normalize.js b/packages/jest-config/src/normalize.js index a15a0489a0fd..e680036c41d9 100644 --- a/packages/jest-config/src/normalize.js +++ b/packages/jest-config/src/normalize.js @@ -362,6 +362,9 @@ function normalize(config: InitialConfig, argv: Object = {}) { case 'persistModuleRegistryBetweenSpecs': case 'preset': case 'replname': + case 'reporters': + value = _replaceRootDirInPath(config.root, config[key]); + break; case 'resetMocks': case 'resetModules': case 'rootDir': From a9e9fcebffea0f11a96a8428fa332c2e0f131278 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sat, 1 Apr 2017 21:34:00 +0500 Subject: [PATCH 18/59] add prettier to types --- types/Config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/types/Config.js b/types/Config.js index 1740605d749d..20d896b5b6d4 100644 --- a/types/Config.js +++ b/types/Config.js @@ -19,7 +19,6 @@ export type HasteConfig = {| providesModuleNodeModules: Array, |}; - export type SimpleReporter = string; export type ComplexReporter = [string, Object]; export type ReporterConfig = Array; From 31b51e39660f239f4aa1286b6a622e641693ff7d Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sat, 1 Apr 2017 21:35:31 +0500 Subject: [PATCH 19/59] Seperate out ReporterDispatcher in a file --- packages/jest-cli/src/ReporterDispatcher.js | 117 ++++++++++++++++++ packages/jest-cli/src/TestRunner.js | 112 +++++------------ .../jest-cli/src/__tests__/TestRunner-test.js | 1 - 3 files changed, 146 insertions(+), 84 deletions(-) create mode 100644 packages/jest-cli/src/ReporterDispatcher.js diff --git a/packages/jest-cli/src/ReporterDispatcher.js b/packages/jest-cli/src/ReporterDispatcher.js new file mode 100644 index 000000000000..45a8b17848e1 --- /dev/null +++ b/packages/jest-cli/src/ReporterDispatcher.js @@ -0,0 +1,117 @@ +import type BaseReporter from './reporters/BaseReporter'; +import type {RunnerContext} from 'types/reporters'; +import type {HasteFS} from 'types/HasteMap'; +import type {Config} from 'types/Config'; + +class ReporterDispatcher { + _disabled: boolean; + _reporters: Array; + _runnerContext: RunnerContext; + + constructor(hasteFS: HasteFS, getTestSummary: () => string) { + this._runnerContext = {getTestSummary, hasteFS}; + this._reporters = []; + + this._requiredMethods = ['getLastError']; + } + + register(reporter: Function): void { + if (this._validateReporter(reporter)) { + this._reporters.push(reporter); + } + } + + unregister(ReporterClass: Function) { + this._reporters = this._reporters.filter( + reporter => !(reporter instanceof ReporterClass), + ); + } + + onTestResult(config: Config, testResult, results) { + this._callReporterMethod('onTestResult', [ + config, + testResult, + results, + this._runnerContext, + ]); + } + + onTestStart(config: Config, path) { + this._callReporterMethod('onTestStart', [ + config, + path, + this._runnerContext, + ]); + } + + onRunStart(config: Config, results, options) { + this._callReporterMethod('onRunStart', [ + config, + results, + this._runnerContext, + options, + ]); + } + + onRunComplete(config: Config, results) { + this._callReporterMethod('onRunComplete', [ + config, + results, + this._runnerContext, + ]); + } + + /** + * Helper mehtod to call only the methods that exist + * on a given reporter + * + * @ private + * @param {string} method name of the mehtod to be called + * @param {Array} reporterArgs arguments passed in to call the reporter + */ + _callReporterMethod(method: string, reporterArgs: Array) { + this._reporters.forEach(reporter => { + if (reporter[method]) { + reporter[method](...reporterArgs); + } + }); + } + + /** + * _validateReporter + * Validates the reporters to be added by checking for the required + * methods + * + * @private + * @param {BaseReporter} reporter reporter to be validated + * @returns {boolean} returns true if the reporter is validated + */ + _validateReporter(reporter: Object | BaseReporter) { + return this._requiredMethods.every(method => { + if (!reporter[method]) { + throw new Error( + `Given method '${method}' does not exist on the reporter: ${reporter}`, + ); + } + + return true; + }); + } + + // Return a list of last errors for every reporter + getErrors(): Array { + return this._reporters.reduce( + (list, reporter) => { + const error = reporter.getLastError(); + return error ? list.concat(error) : list; + }, + [], + ); + } + + hasErrors(): boolean { + return this.getErrors().length !== 0; + } +} + +module.exports = ReporterDispatcher; diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index ed82ac2908ab..a4f47f080392 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -15,11 +15,8 @@ import type { TestResult, } from 'types/TestResult'; import type {Config, ReporterConfig} from 'types/Config'; -import type {HasteFS} from 'types/HasteMap'; import type {Context} from 'types/Context'; -import type {RunnerContext} from 'types/Reporters'; import type {Test, Tests} from 'types/TestRunner'; -import type BaseReporter from './reporters/BaseReporter'; const {formatExecError} = require('jest-message-util'); @@ -33,6 +30,7 @@ const snapshot = require('jest-snapshot'); const throat = require('throat'); const workerFarm = require('worker-farm'); const TestWatcher = require('./TestWatcher'); +const ReporterDispatcher = require('./ReporterDispatcher'); const DEFAULT_REPORTER_LABEL = 'default'; const SLOW_TEST_TIME = 3000; @@ -44,10 +42,6 @@ class CancelRun extends Error { } } -class ReporterValidationError extends Error { - -} - type Options = {| maxWorkers: number, getTestSummary: () => string, @@ -82,7 +76,7 @@ class TestRunner { this._setupReporters(config); } - addReporter(reporter: BaseReporter) { + addReporter(reporter: Function) { this._dispatcher.register(reporter); } @@ -279,22 +273,32 @@ class TestRunner { } /** - * _checkDefaultReporters + * addDefaultReporters + * + * @api private * Checks if we are going to add the default reporters or not + * + * @param {ReporterConfig} reporters Configuration for all the reporters + * @returns {boolean} */ _addDefaultReporters(reporters?: ReporterConfig): boolean { return !reporters || reporters.indexOf(DEFAULT_REPORTER_LABEL) !== -1; } + /** + * Main method to Setup reporters to be used with TestRunner + * + * @param {Config} config + * @api private + */ _setupReporters(config: Config) { const {reporters} = config; - const addDefault = this._addDefaultReporters(reporters); + const isDefault: boolean = this._addDefaultReporters(reporters); - if (addDefault) { + if (isDefault) { this._setupDefaultReporters(config); } - if (reporters && Array.isArray(reporters)) { this._addCustomReporters(reporters); } @@ -318,9 +322,7 @@ class TestRunner { */ _setupDefaultReporters(config: Config) { this.addReporter( - config.verbose - ? new VerboseReporter(config) - : new DefaultReporter() + config.verbose ? new VerboseReporter(config) : new DefaultReporter(), ); this.addReporter(new SummaryReporter()); @@ -368,12 +370,13 @@ class TestRunner { customReporter.forEach(reporter => { try { const { - reporterPath, + reporterPath, reporterConfig = {}, } = this._getReporterProps(reporter); const Reporter = require(reporterPath); this.addReporter(new Reporter(reporterConfig)); } catch (error) { + // TODO A more elaborate error throw error; } }); @@ -383,7 +386,6 @@ class TestRunner { * Vaidates all the Custom Reporters and the format they are specified before * adding them within the application */ - _validateCustomReporters(customReporters: ReporterConfig) { // Validate Custom Reporters here customReporters.forEach((reporter, index) => { @@ -392,27 +394,27 @@ class TestRunner { if (typeof reporterPath !== 'string') { throw new Error( `Expected reporterPath for reporter at index ${index}` + - 'to be string\n' + - 'Got:\n' + - typeof reporter + 'to be of type string\n' + + 'Got:\n' + + typeof reporter, ); } if (reporterConfig && typeof reporterConfig !== 'object') { throw new Error( `Expected configuration for reporter at index ${index}\n` + - 'to be of type object\n' + - 'Got:\n' + - reporterConfig + 'to be of type object\n' + + 'Got:\n' + + reporterConfig, ); } } else if (typeof reporter !== 'string') { throw new Error( `Unexpected Custom Reporter Configuration at index ${index}\n` + - 'Expected:\n' + - `array/string\n` + - 'Got:\n' + - typeof reporter + 'Expected:\n' + + `array/string\n` + + 'Got:\n' + + typeof reporter, ); } }); @@ -542,62 +544,6 @@ const buildFailureTestResult = ( }; }; -class ReporterDispatcher { - _disabled: boolean; - _reporters: Array; - _runnerContext: RunnerContext; - - constructor(hasteFS: HasteFS, getTestSummary: () => string) { - this._runnerContext = {getTestSummary, hasteFS}; - this._reporters = []; - } - - register(reporter: BaseReporter): void { - this._reporters.push(reporter); - } - - unregister(ReporterClass: Function) { - this._reporters = this._reporters.filter( - reporter => !(reporter instanceof ReporterClass), - ); - } - - onTestResult(config, testResult, results) { - this._reporters.forEach(reporter => - reporter.onTestResult(config, testResult, results, this._runnerContext)); - } - - onTestStart(config, path) { - this._reporters.forEach(reporter => - reporter.onTestStart(config, path, this._runnerContext)); - } - - onRunStart(config, results, options) { - this._reporters.forEach(reporter => - reporter.onRunStart(config, results, this._runnerContext, options)); - } - - onRunComplete(config, results) { - this._reporters.forEach(reporter => - reporter.onRunComplete(config, results, this._runnerContext)); - } - - // Return a list of last errors for every reporter - getErrors(): Array { - return this._reporters.reduce( - (list, reporter) => { - const error = reporter.getLastError(); - return error ? list.concat(error) : list; - }, - [], - ); - } - - hasErrors(): boolean { - return this.getErrors().length !== 0; - } -} - const getEstimatedTime = (timings, workers) => { if (!timings.length) { return 0; diff --git a/packages/jest-cli/src/__tests__/TestRunner-test.js b/packages/jest-cli/src/__tests__/TestRunner-test.js index 20a43201c49a..a00188c525d3 100644 --- a/packages/jest-cli/src/__tests__/TestRunner-test.js +++ b/packages/jest-cli/src/__tests__/TestRunner-test.js @@ -96,4 +96,3 @@ describe('_createInBandTestRun()', () => { }); }); }); - From 75e39d1600216a6847f55e2acbd758981b0401bc Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sat, 1 Apr 2017 22:15:25 +0500 Subject: [PATCH 20/59] add elaborate messages for errors --- packages/jest-cli/src/AggregatedResults.js | 3 ++ packages/jest-cli/src/ReporterDispatcher.js | 5 ++- packages/jest-cli/src/TestRunner.js | 43 ++++++++++++--------- 3 files changed, 30 insertions(+), 21 deletions(-) create mode 100644 packages/jest-cli/src/AggregatedResults.js diff --git a/packages/jest-cli/src/AggregatedResults.js b/packages/jest-cli/src/AggregatedResults.js new file mode 100644 index 000000000000..1d18981542b9 --- /dev/null +++ b/packages/jest-cli/src/AggregatedResults.js @@ -0,0 +1,3 @@ +class AggregatedResults { + +} \ No newline at end of file diff --git a/packages/jest-cli/src/ReporterDispatcher.js b/packages/jest-cli/src/ReporterDispatcher.js index 45a8b17848e1..871c8d1e6147 100644 --- a/packages/jest-cli/src/ReporterDispatcher.js +++ b/packages/jest-cli/src/ReporterDispatcher.js @@ -65,7 +65,7 @@ class ReporterDispatcher { * Helper mehtod to call only the methods that exist * on a given reporter * - * @ private + * @private * @param {string} method name of the mehtod to be called * @param {Array} reporterArgs arguments passed in to call the reporter */ @@ -90,7 +90,8 @@ class ReporterDispatcher { return this._requiredMethods.every(method => { if (!reporter[method]) { throw new Error( - `Given method '${method}' does not exist on the reporter: ${reporter}`, + `Given method '${method}' does not exist on the reporter: ` + + (reporter.name || reporter) ); } diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index a4f47f080392..116580caea2e 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -367,24 +367,29 @@ class TestRunner { _addCustomReporters(reporters: ReporterConfig) { this._validateCustomReporters(reporters); const customReporter = reporters.filter(reporter => reporter !== 'default'); - customReporter.forEach(reporter => { + customReporter.forEach((reporter, index) => { + const { + reporterPath, + reporterConfig = {}, + } = this._getReporterProps(reporter); try { - const { - reporterPath, - reporterConfig = {}, - } = this._getReporterProps(reporter); const Reporter = require(reporterPath); this.addReporter(new Reporter(reporterConfig)); } catch (error) { - // TODO A more elaborate error - throw error; + throw new Error( + 'An error occured while adding the reporter at path ' + + reporterPath + ); } }); } /** - * Vaidates all the Custom Reporters and the format they are specified before - * adding them within the application + * Vaidates the Custom Reporter configurations + * and the format they are specified before + * adding them in the application + * + * @param {Array} customReporters */ _validateCustomReporters(customReporters: ReporterConfig) { // Validate Custom Reporters here @@ -394,27 +399,27 @@ class TestRunner { if (typeof reporterPath !== 'string') { throw new Error( `Expected reporterPath for reporter at index ${index}` + - 'to be of type string\n' + - 'Got:\n' + - typeof reporter, + 'to be of type string\n' + + 'Got:\n' + + typeof reporter, ); } if (reporterConfig && typeof reporterConfig !== 'object') { throw new Error( `Expected configuration for reporter at index ${index}\n` + - 'to be of type object\n' + - 'Got:\n' + - reporterConfig, + 'to be of type object\n' + + 'Got:\n' + + reporterConfig, ); } } else if (typeof reporter !== 'string') { throw new Error( `Unexpected Custom Reporter Configuration at index ${index}\n` + - 'Expected:\n' + - `array/string\n` + - 'Got:\n' + - typeof reporter, + 'Expected:\n' + + `array/string\n` + + 'Got:\n' + + typeof reporter, ); } }); From 12e5382804f9ff02e2ec796660b29190b0c422b0 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sat, 1 Apr 2017 22:18:13 +0500 Subject: [PATCH 21/59] add Facebook Copyright header to ReporterDispatcher.js --- packages/jest-cli/src/ReporterDispatcher.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/jest-cli/src/ReporterDispatcher.js b/packages/jest-cli/src/ReporterDispatcher.js index 871c8d1e6147..1f29897b1978 100644 --- a/packages/jest-cli/src/ReporterDispatcher.js +++ b/packages/jest-cli/src/ReporterDispatcher.js @@ -1,3 +1,15 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow + */ + +'use strict'; + import type BaseReporter from './reporters/BaseReporter'; import type {RunnerContext} from 'types/reporters'; import type {HasteFS} from 'types/HasteMap'; From 08bd0cf11a117cf33c5ebb2355765796c47d11f9 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sun, 2 Apr 2017 00:39:22 +0500 Subject: [PATCH 22/59] typecheck and lint properly --- packages/jest-cli/src/AggregatedResults.js | 8 ++-- packages/jest-cli/src/ReporterDispatcher.js | 40 ++++++++++++------- packages/jest-cli/src/TestRunner.js | 10 ++--- .../jest-cli/src/reporters/VerboseReporter.js | 8 +--- packages/jest-config/src/normalize.js | 2 - 5 files changed, 38 insertions(+), 30 deletions(-) diff --git a/packages/jest-cli/src/AggregatedResults.js b/packages/jest-cli/src/AggregatedResults.js index 1d18981542b9..9283de9461d5 100644 --- a/packages/jest-cli/src/AggregatedResults.js +++ b/packages/jest-cli/src/AggregatedResults.js @@ -1,3 +1,5 @@ -class AggregatedResults { - -} \ No newline at end of file +export default class AggregatedResults { + constructor() { + + } +} diff --git a/packages/jest-cli/src/ReporterDispatcher.js b/packages/jest-cli/src/ReporterDispatcher.js index 1f29897b1978..59ca1e1367fc 100644 --- a/packages/jest-cli/src/ReporterDispatcher.js +++ b/packages/jest-cli/src/ReporterDispatcher.js @@ -10,15 +10,23 @@ 'use strict'; -import type BaseReporter from './reporters/BaseReporter'; -import type {RunnerContext} from 'types/reporters'; +import type {RunnerContext} from 'types/Reporters'; import type {HasteFS} from 'types/HasteMap'; -import type {Config} from 'types/Config'; +import type {Config, Path} from 'types/Config'; +import type { + TestResult, AggregatedResult, +} from 'types/TestResult'; + +export type RunOptions = { + estimatedTime: number, + showStatus: boolean, +} class ReporterDispatcher { _disabled: boolean; - _reporters: Array; + _reporters: Array; _runnerContext: RunnerContext; + _requiredMethods: Array; constructor(hasteFS: HasteFS, getTestSummary: () => string) { this._runnerContext = {getTestSummary, hasteFS}; @@ -27,19 +35,23 @@ class ReporterDispatcher { this._requiredMethods = ['getLastError']; } - register(reporter: Function): void { + register(reporter: Object): void { if (this._validateReporter(reporter)) { this._reporters.push(reporter); } } - unregister(ReporterClass: Function) { + unregister(ReporterClass: Function): void { this._reporters = this._reporters.filter( reporter => !(reporter instanceof ReporterClass), ); } - onTestResult(config: Config, testResult, results) { + onTestResult( + config: Config, + testResult: TestResult, + results: AggregatedResult + ) { this._callReporterMethod('onTestResult', [ config, testResult, @@ -48,7 +60,7 @@ class ReporterDispatcher { ]); } - onTestStart(config: Config, path) { + onTestStart(config: Config, path: Path) { this._callReporterMethod('onTestStart', [ config, path, @@ -56,7 +68,7 @@ class ReporterDispatcher { ]); } - onRunStart(config: Config, results, options) { + onRunStart(config: Config, results: AggregatedResult, options: RunOptions) { this._callReporterMethod('onRunStart', [ config, results, @@ -65,7 +77,7 @@ class ReporterDispatcher { ]); } - onRunComplete(config: Config, results) { + onRunComplete(config: Config, results: AggregatedResult) { this._callReporterMethod('onRunComplete', [ config, results, @@ -95,15 +107,15 @@ class ReporterDispatcher { * methods * * @private - * @param {BaseReporter} reporter reporter to be validated + * @param {Object} reporter reporter to be validated * @returns {boolean} returns true if the reporter is validated */ - _validateReporter(reporter: Object | BaseReporter) { + _validateReporter(reporter: Object) { return this._requiredMethods.every(method => { - if (!reporter[method]) { + if (typeof reporter[method] === 'function') { throw new Error( `Given method '${method}' does not exist on the reporter: ` + - (reporter.name || reporter) + reporter.name ); } diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index 116580caea2e..fda54adf3224 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -73,10 +73,10 @@ class TestRunner { this._context = hasteContext; this._options = options; this._startRun = startRun; - this._setupReporters(config); + this._setupReporters(); } - addReporter(reporter: Function) { + addReporter(reporter: Object) { this._dispatcher.register(reporter); } @@ -291,7 +291,8 @@ class TestRunner { * @param {Config} config * @api private */ - _setupReporters(config: Config) { + _setupReporters() { + const config = this._config; const {reporters} = config; const isDefault: boolean = this._addDefaultReporters(reporters); @@ -316,8 +317,7 @@ class TestRunner { } /** - * _setupDefaultReporters - * + * _ * @param {config} Object Config object containing all the options */ _setupDefaultReporters(config: Config) { diff --git a/packages/jest-cli/src/reporters/VerboseReporter.js b/packages/jest-cli/src/reporters/VerboseReporter.js index f4a83f550b71..7e37df66e293 100644 --- a/packages/jest-cli/src/reporters/VerboseReporter.js +++ b/packages/jest-cli/src/reporters/VerboseReporter.js @@ -21,14 +21,10 @@ const DefaultReporter = require('./DefaultReporter'); const chalk = require('chalk'); const {ICONS} = require('../constants'); -type Options = {| - expand: boolean, -|}; - class VerboseReporter extends DefaultReporter { - _options: Options; + _options: Config; - constructor(options: Options) { + constructor(options: Config) { super(); this._options = options; } diff --git a/packages/jest-config/src/normalize.js b/packages/jest-config/src/normalize.js index e680036c41d9..59739ff87320 100644 --- a/packages/jest-config/src/normalize.js +++ b/packages/jest-config/src/normalize.js @@ -363,8 +363,6 @@ function normalize(config: InitialConfig, argv: Object = {}) { case 'preset': case 'replname': case 'reporters': - value = _replaceRootDirInPath(config.root, config[key]); - break; case 'resetMocks': case 'resetModules': case 'rootDir': From 8bf1bb889aea720ed7b5018ee07fe33fa2d4c445 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sun, 2 Apr 2017 05:13:38 +0500 Subject: [PATCH 23/59] correcting a condition in ReporterDispatcher --- packages/jest-cli/src/ReporterDispatcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest-cli/src/ReporterDispatcher.js b/packages/jest-cli/src/ReporterDispatcher.js index 59ca1e1367fc..6d220c21d8c7 100644 --- a/packages/jest-cli/src/ReporterDispatcher.js +++ b/packages/jest-cli/src/ReporterDispatcher.js @@ -112,7 +112,7 @@ class ReporterDispatcher { */ _validateReporter(reporter: Object) { return this._requiredMethods.every(method => { - if (typeof reporter[method] === 'function') { + if (typeof reporter[method] !== 'function') { throw new Error( `Given method '${method}' does not exist on the reporter: ` + reporter.name From 06e71030f0f22ca91d1a6f05482642ef86f5f89a Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sun, 2 Apr 2017 05:14:30 +0500 Subject: [PATCH 24/59] rename method to `_shouldAddDefaultReporters` --- packages/jest-cli/src/TestRunner.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index fda54adf3224..a7b5150001a4 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -273,15 +273,16 @@ class TestRunner { } /** - * addDefaultReporters + * _shouldAddDefaultReporters * * @api private - * Checks if we are going to add the default reporters or not + * Checks if default reporters should be added or not * * @param {ReporterConfig} reporters Configuration for all the reporters - * @returns {boolean} + * @returns {boolean} true if default reporters should be added + * otherwise false */ - _addDefaultReporters(reporters?: ReporterConfig): boolean { + _shouldAddDefaultReporters(reporters?: ReporterConfig): boolean { return !reporters || reporters.indexOf(DEFAULT_REPORTER_LABEL) !== -1; } @@ -376,10 +377,10 @@ class TestRunner { const Reporter = require(reporterPath); this.addReporter(new Reporter(reporterConfig)); } catch (error) { - throw new Error( - 'An error occured while adding the reporter at path ' + - reporterPath + console.error( + 'An error occured while adding the reporter at path ' + reporterPath ); + throw error; } }); } From 32dcff4fb5840b2460f3016abbd3725e6cfc5c12 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Sun, 2 Apr 2017 23:35:18 +0500 Subject: [PATCH 25/59] add integration tests for custom_reporters --- .../custom-reporters-test.js.snap | 71 ++++++++++++++ .../__tests__/custom-reporters-test.js | 96 +++++++++++++++++++ .../__tests__/add-fail-test.js | 9 ++ .../custom_reporters/__tests__/add-test.js | 9 ++ integration_tests/custom_reporters/add.js | 8 ++ .../custom_reporters/package.json | 11 +++ .../reporters/IncompleteReporter.js | 29 ++++++ .../reporters/TestReporter.js | 85 ++++++++++++++++ integration_tests/custom_reporters/yarn.lock | 4 + 9 files changed, 322 insertions(+) create mode 100644 integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap create mode 100644 integration_tests/__tests__/custom-reporters-test.js create mode 100644 integration_tests/custom_reporters/__tests__/add-fail-test.js create mode 100644 integration_tests/custom_reporters/__tests__/add-test.js create mode 100644 integration_tests/custom_reporters/add.js create mode 100644 integration_tests/custom_reporters/package.json create mode 100644 integration_tests/custom_reporters/reporters/IncompleteReporter.js create mode 100644 integration_tests/custom_reporters/reporters/TestReporter.js create mode 100644 integration_tests/custom_reporters/yarn.lock diff --git a/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap b/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap new file mode 100644 index 000000000000..08aa51b7134c --- /dev/null +++ b/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap @@ -0,0 +1,71 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Custom Reporters IncompleteReporter for flexibility 1`] = ` +"onRunComplete is called +Passed Tests: 1 +Failed Tests: 0 +Total Tests: 1 +" +`; + +exports[`Custom Reporters TestReporter with all tests failing 1`] = ` +Object { + "onRunComplete": Object { + "called": true, + "config": "object", + "numFailedTests": 1, + "numPassedTests": 0, + "numTotalTests": 1, + }, + "onRunStart": Object { + "called": true, + "config": "object", + "options": "object", + }, + "onTestResult": Object { + "called": true, + "times": 1, + }, + "onTestStart": Object { + "called": true, + "config": false, + "path": true, + }, + "options": Object { + "option1": "Hello", + "option2": "World", + "option3": "Amazing!!!", + }, +} +`; + +exports[`Custom Reporters TestReporter with all tests passing 1`] = ` +Object { + "onRunComplete": Object { + "called": true, + "config": "object", + "numFailedTests": 0, + "numPassedTests": 1, + "numTotalTests": 1, + }, + "onRunStart": Object { + "called": true, + "config": "object", + "options": "object", + }, + "onTestResult": Object { + "called": true, + "times": 1, + }, + "onTestStart": Object { + "called": true, + "config": false, + "path": true, + }, + "options": Object { + "option1": "Hello", + "option2": "World", + "option3": "Amazing!!!", + }, +} +`; diff --git a/integration_tests/__tests__/custom-reporters-test.js b/integration_tests/__tests__/custom-reporters-test.js new file mode 100644 index 000000000000..006407c4de74 --- /dev/null +++ b/integration_tests/__tests__/custom-reporters-test.js @@ -0,0 +1,96 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +const runJest = require('../runJest'); +const skipOnWindows = require('skipOnWindows'); + +describe('Custom Reporters', () => { + skipOnWindows.suite(); + + test('TestReporter with all tests passing', () => { + const { + stdout, + status, + stderr, + } = runJest('custom_reporters', ['add-test.js']); + let parsedJSON; + + try { + parsedJSON = JSON.parse(stdout); + } catch (error) { + throw new Error( + 'Failed to parse JSON, Check the Output of TestReporter' + ); + } + + const {onRunComplete, onRunStart, onTestResult, onTestStart} = parsedJSON; + + expect(status).toBe(0); + expect(stderr.trim()).toBeFalsy(); + + expect(onRunComplete.numPassedTests).toBe(1); + expect(onRunComplete.numFailedTests).toBe(0); + expect(onRunComplete.numTotalTests).toBe(1); + + expect(onRunStart.called).toBeTruthy(); + expect(onTestResult.called).toBeTruthy(); + expect(onTestStart.called).toBeTruthy(); + + expect(parsedJSON).toMatchSnapshot(); + }); + + test('TestReporter with all tests failing', () => { + let parsedJSON; + const { + stdout, + status, + stderr, + } = runJest('custom_reporters', ['add-fail-test.js']); + + try { + parsedJSON = JSON.parse(stdout); + } catch (error) { + throw new Error('Failed to parse JSON. Check the output of TestReporter'); + } + + const {onTestStart, onTestResult, onRunStart, onRunComplete} = parsedJSON; + + expect(status).toBe(1); + expect(stderr).toBeFalsy(); + + expect(onRunComplete.numPassedTests).toBe(0); + expect(onRunComplete.numFailedTests).toBe(1); + expect(onRunComplete.numTotalTests).toBe(1); + + expect(onRunStart.called).toBeTruthy(); + expect(onTestStart.called).toBeTruthy(); + expect(onTestResult.called).toBeTruthy(); + + expect(parsedJSON).toMatchSnapshot(); + }); + + test('IncompleteReporter for flexibility', () => { + const {stdout, status} = runJest('custom_reporters', [ + '--config', + JSON.stringify({ + 'reporters': [ + '/reporters/IncompleteReporter.js', + ], + }), + 'add-test.js', + ]); + + expect(status).toBe(0); + + expect(stdout).toMatch('onRunComplete is called'); + expect(stdout).toMatch('Passed Tests: 1'); + expect(stdout).toMatch('Failed Tests: 0'); + expect(stdout).toMatch('Total Tests: 1'); + + expect(stdout).toMatchSnapshot(); + }); +}); diff --git a/integration_tests/custom_reporters/__tests__/add-fail-test.js b/integration_tests/custom_reporters/__tests__/add-fail-test.js new file mode 100644 index 000000000000..e81456dbcad3 --- /dev/null +++ b/integration_tests/custom_reporters/__tests__/add-fail-test.js @@ -0,0 +1,9 @@ +const add = require('../add'); + +describe('CustomReporters', () => { + test('adds fail', () => { + expect(add(1, 3)).toBe(231); + expect(add(5, 7)).toBe(120); + expect(add(2, 4)).toBe(6); + }); +}); diff --git a/integration_tests/custom_reporters/__tests__/add-test.js b/integration_tests/custom_reporters/__tests__/add-test.js new file mode 100644 index 000000000000..3f1e1364122b --- /dev/null +++ b/integration_tests/custom_reporters/__tests__/add-test.js @@ -0,0 +1,9 @@ +const add = require('../add'); + +describe('Custom Reporters', () => { + test('adds ok', () => { + expect(add(1, 2)).toBe(3); + expect(add(3, 4)).toBe(7); + expect(add(12, 24)).toBe(36); + }); +}); diff --git a/integration_tests/custom_reporters/add.js b/integration_tests/custom_reporters/add.js new file mode 100644 index 000000000000..4250ae2ea601 --- /dev/null +++ b/integration_tests/custom_reporters/add.js @@ -0,0 +1,8 @@ +/** + * add + * @param {Number} x + * @param {Number} y + */ +module.exports = function add(x, y) { + return x + y; +}; diff --git a/integration_tests/custom_reporters/package.json b/integration_tests/custom_reporters/package.json new file mode 100644 index 000000000000..184fd4f492ad --- /dev/null +++ b/integration_tests/custom_reporters/package.json @@ -0,0 +1,11 @@ +{ + "jest": { + "reporters": [ + ["/reporters/TestReporter.js", { + "option1": "Hello", + "option2": "World", + "option3": "Amazing!!!" + }] + ] + } +} diff --git a/integration_tests/custom_reporters/reporters/IncompleteReporter.js b/integration_tests/custom_reporters/reporters/IncompleteReporter.js new file mode 100644 index 000000000000..09c4e479004b --- /dev/null +++ b/integration_tests/custom_reporters/reporters/IncompleteReporter.js @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/** + * IncompleteReporter + * Reporter to test for the flexibility of the interface we implemented. + * The reporters shouldn't be required to implement all the methods + * + * This only implements one mehtod onRunComplete which should be called + */ +class IncompleteReporter { + constructor(options) { + this.options = {}; + } + + onRunComplete(config, results) { + console.log('onRunComplete is called'); + console.log('Passed Tests: ' + results.numPassedTests); + console.log('Failed Tests: ' + results.numFailedTests); + console.log('Total Tests: ' + results.numTotalTests); + } +} + +module.exports = IncompleteReporter; diff --git a/integration_tests/custom_reporters/reporters/TestReporter.js b/integration_tests/custom_reporters/reporters/TestReporter.js new file mode 100644 index 000000000000..678d64c4fdad --- /dev/null +++ b/integration_tests/custom_reporters/reporters/TestReporter.js @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/** + * TestReporter + * Reporter for testing the outputs, without any extra + * hassle. Uses a JSON like syntax for testing the reporters + * instead of outputting the text to stdout and using match functions + * to get the output. + */ +class TestReporter { + constructor(options) { + this._options = options; + + /** + * statsCollected property + * contains most of the statistics + * related to the object to be called, + * This here helps us in avoiding the string match + * statements nothing else + */ + this._statsCollected = { + onRunComplete: {}, + onRunStart: {}, + onTestResult: {times: 0}, + onTestStart: {}, + options, + }; + } + + /** + * clearLine + * clears the line for easier JSON parsing + */ + clearLine() { + if (process.stdout.isTTY) { + process.stderr.write('\x1b[999D\x1b[K'); + } + } + + onTestStart(config, path) { + const {onTestStart} = this._statsCollected; + + onTestStart.called = true; + onTestStart.config = config === undefined; + onTestStart.path = typeof path === 'string'; + } + + onTestResult(config, testResult, results) { + const {onTestResult} = this._statsCollected; + + onTestResult.called = true; + onTestResult.times++; + } + + onRunStart(config, results, options) { + this.clearLine(); + const {onRunStart} = this._statsCollected; + + onRunStart.called = true; + onRunStart.config = typeof config; + onRunStart.options = typeof options; + } + + onRunComplete(config, results) { + const {onRunComplete} = this._statsCollected; + + onRunComplete.called = true; + onRunComplete.config = typeof config; + + onRunComplete.numPassedTests = results.numPassedTests; + onRunComplete.numFailedTests = results.numFailedTests; + onRunComplete.numTotalTests = results.numTotalTests; + + // The Final Call + process.stdout.write(JSON.stringify(this._statsCollected, null, 4)); + } +} + +module.exports = TestReporter; diff --git a/integration_tests/custom_reporters/yarn.lock b/integration_tests/custom_reporters/yarn.lock new file mode 100644 index 000000000000..fb57ccd13afb --- /dev/null +++ b/integration_tests/custom_reporters/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + From 45656ad5093d3943beff529749d38e7606ac50c7 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 3 Apr 2017 00:16:39 +0500 Subject: [PATCH 26/59] add more complete integration tests for reporters --- .../custom-reporters-test.js.snap | 6 +-- .../__tests__/custom-reporters-test.js | 54 ++++++++++++++++++- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap b/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap index 08aa51b7134c..0ba353a19cef 100644 --- a/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap +++ b/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Custom Reporters IncompleteReporter for flexibility 1`] = ` +exports[`Custom Reporters Integration IncompleteReporter for flexibility 1`] = ` "onRunComplete is called Passed Tests: 1 Failed Tests: 0 @@ -8,7 +8,7 @@ Total Tests: 1 " `; -exports[`Custom Reporters TestReporter with all tests failing 1`] = ` +exports[`Custom Reporters Integration TestReporter with all tests failing 1`] = ` Object { "onRunComplete": Object { "called": true, @@ -39,7 +39,7 @@ Object { } `; -exports[`Custom Reporters TestReporter with all tests passing 1`] = ` +exports[`Custom Reporters Integration TestReporter with all tests passing 1`] = ` Object { "onRunComplete": Object { "called": true, diff --git a/integration_tests/__tests__/custom-reporters-test.js b/integration_tests/__tests__/custom-reporters-test.js index 006407c4de74..ab910a421056 100644 --- a/integration_tests/__tests__/custom-reporters-test.js +++ b/integration_tests/__tests__/custom-reporters-test.js @@ -8,8 +8,60 @@ const runJest = require('../runJest'); const skipOnWindows = require('skipOnWindows'); -describe('Custom Reporters', () => { +describe('Custom Reporters Integration', () => { + // Skipping on Windows, cos this till is only being tested on a + // Linux machine, if you have guts, test it on Windows, + // and remove this if it works fine there. <3 skipOnWindows.suite(); + + test('valid string format for adding reporters', () => { + const reporterConfig = { + 'reporters': [ + '/reporters/TestReporter.js', + ], + }; + + const {status} = runJest('custom_reporters', [ + '--config', + JSON.stringify(reporterConfig), + 'add-test.js', + ]); + + expect(status).toBe(0); + }); + + test('valid array format for adding reporters', () => { + const reporterConfig = { + 'reporters': [ + ['/reporters/TestReporter.js', {'Dmitrii Abramov': 'Awesome'}], + ], + }; + + const {status} = runJest('custom_reporters', [ + '--config', + JSON.stringify(reporterConfig), + 'add-test.js', + ]); + + expect(status).toBe(0); + }); + + test('invalid format for adding reporters', () => { + const reporterConfig = { + 'reporters': [ + [3243242], + ], + }; + + const {status, stderr} = runJest('custom_reporters', [ + '--config', + JSON.stringify(reporterConfig), + 'add-test.js', + ]); + + expect(stderr).toMatch('Expected reporterPath for reporter'); + expect(status).toBe(1); + }); test('TestReporter with all tests passing', () => { const { From 15abe4ed2510b7c6661c04281b8c52cd3db2af07 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 3 Apr 2017 00:41:51 +0500 Subject: [PATCH 27/59] remove AggregatedResults.js --- packages/jest-cli/src/AggregatedResults.js | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 packages/jest-cli/src/AggregatedResults.js diff --git a/packages/jest-cli/src/AggregatedResults.js b/packages/jest-cli/src/AggregatedResults.js deleted file mode 100644 index 9283de9461d5..000000000000 --- a/packages/jest-cli/src/AggregatedResults.js +++ /dev/null @@ -1,5 +0,0 @@ -export default class AggregatedResults { - constructor() { - - } -} From 76ebadb92a89b9a709d9e34ae38db5e5d6bbe249 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 3 Apr 2017 00:42:11 +0500 Subject: [PATCH 28/59] remove any methods to be validated --- packages/jest-cli/src/ReporterDispatcher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jest-cli/src/ReporterDispatcher.js b/packages/jest-cli/src/ReporterDispatcher.js index 6d220c21d8c7..96f21d0b118d 100644 --- a/packages/jest-cli/src/ReporterDispatcher.js +++ b/packages/jest-cli/src/ReporterDispatcher.js @@ -32,7 +32,7 @@ class ReporterDispatcher { this._runnerContext = {getTestSummary, hasteFS}; this._reporters = []; - this._requiredMethods = ['getLastError']; + this._requiredMethods = []; } register(reporter: Object): void { @@ -127,7 +127,7 @@ class ReporterDispatcher { getErrors(): Array { return this._reporters.reduce( (list, reporter) => { - const error = reporter.getLastError(); + const error = reporter.getLastError && reporter.getLastError(); return error ? list.concat(error) : list; }, [], From e158496fce2e1c2ba9e589067a5926b458458d83 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 3 Apr 2017 00:43:12 +0500 Subject: [PATCH 29/59] correct _addDefaultReporters call --- packages/jest-cli/src/TestRunner.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index a7b5150001a4..041f5fcc9d9b 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -272,9 +272,7 @@ class TestRunner { return Promise.race([runAllTests, onInterrupt]).then(cleanup, cleanup); } - /** - * _shouldAddDefaultReporters - * + /** * @api private * Checks if default reporters should be added or not * @@ -295,7 +293,7 @@ class TestRunner { _setupReporters() { const config = this._config; const {reporters} = config; - const isDefault: boolean = this._addDefaultReporters(reporters); + const isDefault: boolean = this._shouldAddDefaultReporters(reporters); if (isDefault) { this._setupDefaultReporters(config); From 80c88dbb7608aa8ebb0bf9c6512360a957e06473 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 3 Apr 2017 07:44:13 +0500 Subject: [PATCH 30/59] remove "reporters" validations from TestRunner.js --- packages/jest-cli/src/TestRunner.js | 44 ++--------------------------- 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index 041f5fcc9d9b..c3473ca81157 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -364,13 +364,14 @@ class TestRunner { * */ _addCustomReporters(reporters: ReporterConfig) { - this._validateCustomReporters(reporters); const customReporter = reporters.filter(reporter => reporter !== 'default'); + customReporter.forEach((reporter, index) => { const { reporterPath, reporterConfig = {}, } = this._getReporterProps(reporter); + try { const Reporter = require(reporterPath); this.addReporter(new Reporter(reporterConfig)); @@ -383,47 +384,6 @@ class TestRunner { }); } - /** - * Vaidates the Custom Reporter configurations - * and the format they are specified before - * adding them in the application - * - * @param {Array} customReporters - */ - _validateCustomReporters(customReporters: ReporterConfig) { - // Validate Custom Reporters here - customReporters.forEach((reporter, index) => { - if (Array.isArray(reporter)) { - const [reporterPath, reporterConfig] = reporter; - if (typeof reporterPath !== 'string') { - throw new Error( - `Expected reporterPath for reporter at index ${index}` + - 'to be of type string\n' + - 'Got:\n' + - typeof reporter, - ); - } - - if (reporterConfig && typeof reporterConfig !== 'object') { - throw new Error( - `Expected configuration for reporter at index ${index}\n` + - 'to be of type object\n' + - 'Got:\n' + - reporterConfig, - ); - } - } else if (typeof reporter !== 'string') { - throw new Error( - `Unexpected Custom Reporter Configuration at index ${index}\n` + - 'Expected:\n' + - `array/string\n` + - 'Got:\n' + - typeof reporter, - ); - } - }); - } - _bailIfNeeded(aggregatedResults: AggregatedResult, watcher: TestWatcher) { if (this._config.bail && aggregatedResults.numFailedTests !== 0) { if (watcher.isWatchMode()) { From 4a33e50c3c5225f91e9538eed90dfee1d2b7417f Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 3 Apr 2017 07:45:07 +0500 Subject: [PATCH 31/59] add pretty validations for custom reporters --- .../src/reporterValidationErrors.js | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 packages/jest-config/src/reporterValidationErrors.js diff --git a/packages/jest-config/src/reporterValidationErrors.js b/packages/jest-config/src/reporterValidationErrors.js new file mode 100644 index 000000000000..c719d0d450de --- /dev/null +++ b/packages/jest-config/src/reporterValidationErrors.js @@ -0,0 +1,119 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +// Many parts of this code should be handled +// by `jest-validate` + +const {ValidationError} = require('jest-validate'); +const {DOCUMENTATION_NOTE, BULLET} = require('./utils'); + +const chalk = require('chalk'); +const {getType} = require('jest-matcher-utils'); + +const validReporterTypes = ['array', 'string']; +const ERROR = `${BULLET} Reporter Validation Error`; + +/** + * Reporter Vaidation Error is thrown if the given arguments + * within the reporter are not valid + * + * This is a highly specific reporter error and in the future will be + * merged with jest-validate. Till then, we can make use of it. It works + * and that's what counts most at this time + * + * @param {Number} reporterIndex specific index at which reporter is present + * @param {any} reporterValue value of the reporter, anything output by the user + * + * @returns {ValidationError} validation error which can be thrown if needed + * + */ +function createReporterError( + reporterIndex:number, reporterValue: any +) : ValidationError { + const errorMessage = ( + `\tReporter at index ${reporterIndex} must be of type:\n` + + `\t\t${chalk.bold.green(validReporterTypes.join(' or '))}\n` + + `\tbut instead received:\n` + + `\t\t${chalk.bold.red(getType(reporterValue))}` + ); + + return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); +} + +/** + * createArrayReporterError + * + * Reporter Error specific to Array configuration + * + * @param {Number} reporterIndex index for the given reporter config + * @param {Number} valueIndex index of the + * @param {any} value value provided by the reporter + * @param {any} expected expected value for the reporter + * + * @returns {ValidationError} ValidationError + */ +function createArrayReporterError( + reporterIndex: number, + valueIndex: number, + value: any, + expected: any, + valueName: string +): ValidationError { + const errorMessage = ( + `\tUnexpected value for ${valueName} at index ${valueIndex} of reporter` + + `at index ${reporterIndex}\n` + + '\tExpected:\n' + + `\t\t${chalk.bold.red(getType(expected))}\n` + + '\tGot:\n' + + `\t\t${chalk.bold.green(getType(value))}` + ); + + return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); +} + +/** + * valiates the each reporter within the reporters + * using appropriate values + * + * @param {Array} reporterConfig configuration for the given reporter + * @returns {boolean} true if all the given reporters are valid + */ +function validateReporters(reporterConfig: Array) : boolean { + return reporterConfig.every((reporter, index) => { + if (Array.isArray(reporter)) { + throw validateArrayReporter(reporter, index); + } else if (typeof reporter !== 'string') { + throw createReporterError(index, reporter); + } + + return true; + }); +} + +/** + * validates values within the array reporter + * + * @param {Array} arrayReporter reporter to be validated + * @returns {boolean} true if the reporter was validated + */ +function validateArrayReporter(arrayReporter, reporterIndex) { + const [path, options] = arrayReporter; + if (typeof path !== 'string') { + throw createArrayReporterError(reporterIndex, 0, path, '', 'Path'); + } else if (typeof options !== 'object') { + throw createArrayReporterError( + reporterIndex, 1, options, {}, 'Reporter Configuration' + ); + } +} + +module.exports = { + createArrayReporterError, + createReporterError, + validateReporters, +}; From 352f2196df35e2aaca4dc403b6d8affd42018776 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 3 Apr 2017 18:51:47 +0500 Subject: [PATCH 32/59] remove comment --- packages/jest-config/src/reporterValidationErrors.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/jest-config/src/reporterValidationErrors.js b/packages/jest-config/src/reporterValidationErrors.js index c719d0d450de..8ecfc72ace14 100644 --- a/packages/jest-config/src/reporterValidationErrors.js +++ b/packages/jest-config/src/reporterValidationErrors.js @@ -5,10 +5,6 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ - -// Many parts of this code should be handled -// by `jest-validate` - const {ValidationError} = require('jest-validate'); const {DOCUMENTATION_NOTE, BULLET} = require('./utils'); From 03c20455632ddc389274b6e6be1851dc631821ff Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 3 Apr 2017 18:52:22 +0500 Subject: [PATCH 33/59] add reporter validation in normalize.js --- packages/jest-config/src/normalize.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/jest-config/src/normalize.js b/packages/jest-config/src/normalize.js index 59739ff87320..537b184bfc37 100644 --- a/packages/jest-config/src/normalize.js +++ b/packages/jest-config/src/normalize.js @@ -32,6 +32,7 @@ const DEPRECATED_CONFIG = require('./deprecated'); const JSON_EXTENSION = '.json'; const PRESET_NAME = 'jest-preset' + JSON_EXTENSION; const ERROR = `${BULLET}Validation Error`; +const {validateReporters} = require('./reporterValidationErrors'); const createConfigError = message => new ValidationError(ERROR, message, DOCUMENTATION_NOTE); @@ -250,6 +251,7 @@ function normalize(config: InitialConfig, argv: Object = {}) { deprecatedConfig: DEPRECATED_CONFIG, exampleConfig: VALID_CONFIG, }); + validateReporters(config.reporters); normalizePreprocessor(config); normalizeRootDir(config); From 8dd5ef351dd92f16ec444dcc94ff0ad9b56ab3c8 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 3 Apr 2017 18:53:38 +0500 Subject: [PATCH 34/59] keep comments precise remove unwanted --- integration_tests/__tests__/custom-reporters-test.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/integration_tests/__tests__/custom-reporters-test.js b/integration_tests/__tests__/custom-reporters-test.js index ab910a421056..c22f18190c03 100644 --- a/integration_tests/__tests__/custom-reporters-test.js +++ b/integration_tests/__tests__/custom-reporters-test.js @@ -9,9 +9,6 @@ const runJest = require('../runJest'); const skipOnWindows = require('skipOnWindows'); describe('Custom Reporters Integration', () => { - // Skipping on Windows, cos this till is only being tested on a - // Linux machine, if you have guts, test it on Windows, - // and remove this if it works fine there. <3 skipOnWindows.suite(); test('valid string format for adding reporters', () => { From 27c553377f3305865ecd40bc027ea24a84a016b0 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 3 Apr 2017 19:10:14 +0500 Subject: [PATCH 35/59] check if reporters exist before validation --- packages/jest-config/src/normalize.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/jest-config/src/normalize.js b/packages/jest-config/src/normalize.js index 537b184bfc37..201b091408ed 100644 --- a/packages/jest-config/src/normalize.js +++ b/packages/jest-config/src/normalize.js @@ -251,7 +251,10 @@ function normalize(config: InitialConfig, argv: Object = {}) { deprecatedConfig: DEPRECATED_CONFIG, exampleConfig: VALID_CONFIG, }); - validateReporters(config.reporters); + + if (config.reporters && Array.isArray(config.reporters)) { + validateReporters(config.reporters); + } normalizePreprocessor(config); normalizeRootDir(config); From cebb62e2c6c3b15d11a1beb16c6773869555e8dc Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Tue, 4 Apr 2017 23:27:14 +0500 Subject: [PATCH 36/59] pretty custom reporters --- .../__tests__/custom-reporters-test.js | 25 +++++++------------ integration_tests/custom_reporters/yarn.lock | 4 --- 2 files changed, 9 insertions(+), 20 deletions(-) delete mode 100644 integration_tests/custom_reporters/yarn.lock diff --git a/integration_tests/__tests__/custom-reporters-test.js b/integration_tests/__tests__/custom-reporters-test.js index c22f18190c03..3e1222fe15e8 100644 --- a/integration_tests/__tests__/custom-reporters-test.js +++ b/integration_tests/__tests__/custom-reporters-test.js @@ -13,23 +13,22 @@ describe('Custom Reporters Integration', () => { test('valid string format for adding reporters', () => { const reporterConfig = { - 'reporters': [ - '/reporters/TestReporter.js', - ], + reporters: ['/reporters/TestReporter.js'], }; - const {status} = runJest('custom_reporters', [ + const {status, stdout} = runJest('custom_reporters', [ '--config', JSON.stringify(reporterConfig), 'add-test.js', ]); + console.log(stdout); expect(status).toBe(0); }); test('valid array format for adding reporters', () => { const reporterConfig = { - 'reporters': [ + reporters: [ ['/reporters/TestReporter.js', {'Dmitrii Abramov': 'Awesome'}], ], }; @@ -45,9 +44,7 @@ describe('Custom Reporters Integration', () => { test('invalid format for adding reporters', () => { const reporterConfig = { - 'reporters': [ - [3243242], - ], + reporters: [[3243242]], }; const {status, stderr} = runJest('custom_reporters', [ @@ -59,7 +56,7 @@ describe('Custom Reporters Integration', () => { expect(stderr).toMatch('Expected reporterPath for reporter'); expect(status).toBe(1); }); - + test('TestReporter with all tests passing', () => { const { stdout, @@ -71,9 +68,7 @@ describe('Custom Reporters Integration', () => { try { parsedJSON = JSON.parse(stdout); } catch (error) { - throw new Error( - 'Failed to parse JSON, Check the Output of TestReporter' - ); + throw new Error('Failed to parse JSON, Check the Output of TestReporter'); } const {onRunComplete, onRunStart, onTestResult, onTestStart} = parsedJSON; @@ -99,7 +94,7 @@ describe('Custom Reporters Integration', () => { status, stderr, } = runJest('custom_reporters', ['add-fail-test.js']); - + try { parsedJSON = JSON.parse(stdout); } catch (error) { @@ -126,9 +121,7 @@ describe('Custom Reporters Integration', () => { const {stdout, status} = runJest('custom_reporters', [ '--config', JSON.stringify({ - 'reporters': [ - '/reporters/IncompleteReporter.js', - ], + reporters: ['/reporters/IncompleteReporter.js'], }), 'add-test.js', ]); diff --git a/integration_tests/custom_reporters/yarn.lock b/integration_tests/custom_reporters/yarn.lock deleted file mode 100644 index fb57ccd13afb..000000000000 --- a/integration_tests/custom_reporters/yarn.lock +++ /dev/null @@ -1,4 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - From e36d4427e9a7ca1eb156bf6fc7e78c3f97285d64 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Tue, 4 Apr 2017 23:29:09 +0500 Subject: [PATCH 37/59] prettier integration_tests --- integration_tests/__tests__/failures-test.js | 16 ++++------------ .../custom_reporters/__tests__/add-test.js | 10 +++++----- integration_tests/custom_reporters/package.json | 15 ++++++--------- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/integration_tests/__tests__/failures-test.js b/integration_tests/__tests__/failures-test.js index 173bed6d0ce5..5e427357fab5 100644 --- a/integration_tests/__tests__/failures-test.js +++ b/integration_tests/__tests__/failures-test.js @@ -28,19 +28,11 @@ const stripInconsistentStackLines = summary => { test('throwing not Error objects', () => { let stderr; stderr = runJest(dir, ['throw-number-test.js']).stderr; - expect(stripInconsistentStackLines( - extractSummary(stderr), - )).toMatchSnapshot(); + expect(stripInconsistentStackLines(extractSummary(stderr))).toMatchSnapshot(); stderr = runJest(dir, ['throw-string-test.js']).stderr; - expect(stripInconsistentStackLines( - extractSummary(stderr), - )).toMatchSnapshot(); + expect(stripInconsistentStackLines(extractSummary(stderr))).toMatchSnapshot(); stderr = runJest(dir, ['throw-object-test.js']).stderr; - expect(stripInconsistentStackLines( - extractSummary(stderr), - )).toMatchSnapshot(); + expect(stripInconsistentStackLines(extractSummary(stderr))).toMatchSnapshot(); stderr = runJest(dir, ['assertion-count-test.js']).stderr; - expect(stripInconsistentStackLines( - extractSummary(stderr), - )).toMatchSnapshot(); + expect(stripInconsistentStackLines(extractSummary(stderr))).toMatchSnapshot(); }); diff --git a/integration_tests/custom_reporters/__tests__/add-test.js b/integration_tests/custom_reporters/__tests__/add-test.js index 3f1e1364122b..a2130ede580c 100644 --- a/integration_tests/custom_reporters/__tests__/add-test.js +++ b/integration_tests/custom_reporters/__tests__/add-test.js @@ -1,9 +1,9 @@ const add = require('../add'); describe('Custom Reporters', () => { - test('adds ok', () => { - expect(add(1, 2)).toBe(3); - expect(add(3, 4)).toBe(7); - expect(add(12, 24)).toBe(36); - }); + test('adds ok', () => { + expect(add(1, 2)).toBe(3); + expect(add(3, 4)).toBe(7); + expect(add(12, 24)).toBe(36); + }); }); diff --git a/integration_tests/custom_reporters/package.json b/integration_tests/custom_reporters/package.json index 184fd4f492ad..43d4441b363a 100644 --- a/integration_tests/custom_reporters/package.json +++ b/integration_tests/custom_reporters/package.json @@ -1,11 +1,8 @@ { - "jest": { - "reporters": [ - ["/reporters/TestReporter.js", { - "option1": "Hello", - "option2": "World", - "option3": "Amazing!!!" - }] - ] - } + "jest": { + "reporters": [ + 132231332, + ["akljda", 2121] + ] + } } From 593040c2bc644c087789da9d86090b7cabff608d Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Tue, 4 Apr 2017 23:30:58 +0500 Subject: [PATCH 38/59] prettier --- packages/jest-editor-support/src/parsers/BabylonParser.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/jest-editor-support/src/parsers/BabylonParser.js b/packages/jest-editor-support/src/parsers/BabylonParser.js index a2a36dcb8862..e1e535f4002f 100644 --- a/packages/jest-editor-support/src/parsers/BabylonParser.js +++ b/packages/jest-editor-support/src/parsers/BabylonParser.js @@ -23,7 +23,6 @@ const cache = Object.create(null); // This is a copy of babel-jest's parser, but it takes create-react-app // into account, and will return an empty JSON object instead of "". const getBabelRC = (filename, {useCache}) => { - // Special case for create-react-app, which hides the .babelrc const paths: string[] = ['node_modules/react-scripts/']; let directory = filename; From c94c99336be0c11b11db62e0e31ed3c6a840aa97 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Tue, 4 Apr 2017 23:34:26 +0500 Subject: [PATCH 39/59] yarn prettier --- .../src/reporterValidationErrors.js | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/packages/jest-config/src/reporterValidationErrors.js b/packages/jest-config/src/reporterValidationErrors.js index 8ecfc72ace14..2241a2ca02ce 100644 --- a/packages/jest-config/src/reporterValidationErrors.js +++ b/packages/jest-config/src/reporterValidationErrors.js @@ -29,16 +29,15 @@ const ERROR = `${BULLET} Reporter Validation Error`; * */ function createReporterError( - reporterIndex:number, reporterValue: any -) : ValidationError { - const errorMessage = ( - `\tReporter at index ${reporterIndex} must be of type:\n` + - `\t\t${chalk.bold.green(validReporterTypes.join(' or '))}\n` + - `\tbut instead received:\n` + - `\t\t${chalk.bold.red(getType(reporterValue))}` - ); + reporterIndex: number, + reporterValue: any, +): ValidationError { + const errorMessage = `\tReporter at index ${reporterIndex} must be of type:\n` + + `\t\t${chalk.bold.green(validReporterTypes.join(' or '))}\n` + + `\tbut instead received:\n` + + `\t\t${chalk.bold.red(getType(reporterValue))}`; - return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); + return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); } /** @@ -54,22 +53,20 @@ function createReporterError( * @returns {ValidationError} ValidationError */ function createArrayReporterError( - reporterIndex: number, - valueIndex: number, - value: any, - expected: any, - valueName: string + reporterIndex: number, + valueIndex: number, + value: any, + expected: any, + valueName: string, ): ValidationError { - const errorMessage = ( - `\tUnexpected value for ${valueName} at index ${valueIndex} of reporter` + - `at index ${reporterIndex}\n` + - '\tExpected:\n' + - `\t\t${chalk.bold.red(getType(expected))}\n` + - '\tGot:\n' + - `\t\t${chalk.bold.green(getType(value))}` - ); + const errorMessage = `\tUnexpected value for ${valueName} at index ${valueIndex} of reporter` + + `at index ${reporterIndex}\n` + + '\tExpected:\n' + + `\t\t${chalk.bold.red(getType(expected))}\n` + + '\tGot:\n' + + `\t\t${chalk.bold.green(getType(value))}`; - return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); + return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); } /** @@ -79,7 +76,7 @@ function createArrayReporterError( * @param {Array} reporterConfig configuration for the given reporter * @returns {boolean} true if all the given reporters are valid */ -function validateReporters(reporterConfig: Array) : boolean { +function validateReporters(reporterConfig: Array): boolean { return reporterConfig.every((reporter, index) => { if (Array.isArray(reporter)) { throw validateArrayReporter(reporter, index); @@ -103,13 +100,17 @@ function validateArrayReporter(arrayReporter, reporterIndex) { throw createArrayReporterError(reporterIndex, 0, path, '', 'Path'); } else if (typeof options !== 'object') { throw createArrayReporterError( - reporterIndex, 1, options, {}, 'Reporter Configuration' + reporterIndex, + 1, + options, + {}, + 'Reporter Configuration', ); } } module.exports = { - createArrayReporterError, - createReporterError, - validateReporters, + createArrayReporterError, + createReporterError, + validateReporters, }; From fc8a4d3e33397145ed749c311d76cdc2c2fb2c26 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Tue, 4 Apr 2017 23:34:53 +0500 Subject: [PATCH 40/59] prettier --- packages/jest-cli/src/ReporterDispatcher.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/jest-cli/src/ReporterDispatcher.js b/packages/jest-cli/src/ReporterDispatcher.js index 96f21d0b118d..e034c6fcfabf 100644 --- a/packages/jest-cli/src/ReporterDispatcher.js +++ b/packages/jest-cli/src/ReporterDispatcher.js @@ -13,14 +13,12 @@ import type {RunnerContext} from 'types/Reporters'; import type {HasteFS} from 'types/HasteMap'; import type {Config, Path} from 'types/Config'; -import type { - TestResult, AggregatedResult, -} from 'types/TestResult'; +import type {TestResult, AggregatedResult} from 'types/TestResult'; export type RunOptions = { estimatedTime: number, showStatus: boolean, -} +}; class ReporterDispatcher { _disabled: boolean; @@ -49,8 +47,8 @@ class ReporterDispatcher { onTestResult( config: Config, - testResult: TestResult, - results: AggregatedResult + testResult: TestResult, + results: AggregatedResult, ) { this._callReporterMethod('onTestResult', [ config, @@ -115,7 +113,7 @@ class ReporterDispatcher { if (typeof reporter[method] !== 'function') { throw new Error( `Given method '${method}' does not exist on the reporter: ` + - reporter.name + reporter.name, ); } From cfdcccf5b32a86289248b66269491aac7ec7216e Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Wed, 5 Apr 2017 01:18:18 +0500 Subject: [PATCH 41/59] Remove unnecessary comments from TestRunner.js --- packages/jest-cli/src/TestRunner.js | 71 ++++++++++------------------- 1 file changed, 23 insertions(+), 48 deletions(-) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index c3473ca81157..e3585eb081d5 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -273,12 +273,8 @@ class TestRunner { } /** - * @api private * Checks if default reporters should be added or not - * - * @param {ReporterConfig} reporters Configuration for all the reporters - * @returns {boolean} true if default reporters should be added - * otherwise false + * @private */ _shouldAddDefaultReporters(reporters?: ReporterConfig): boolean { return !reporters || reporters.indexOf(DEFAULT_REPORTER_LABEL) !== -1; @@ -286,9 +282,7 @@ class TestRunner { /** * Main method to Setup reporters to be used with TestRunner - * - * @param {Config} config - * @api private + * @private */ _setupReporters() { const config = this._config; @@ -327,63 +321,44 @@ class TestRunner { this.addReporter(new SummaryReporter()); } - /** - * gets the props for the given custom reporter, whether reporter is - * defined as a String or an Array to make things simple for us. - */ - _getReporterProps(reporter: any): Object { - const props = {}; - let reporterPath, reporterConfig; - - if (typeof reporter === 'string') { - reporterPath = reporter; - } else if (Array.isArray(reporter)) { - [reporterPath, reporterConfig] = reporter; - } - - props['reporterPath'] = reporterPath; - props['reporterConfig'] = reporterConfig; - - return props; - } - /** * Adds Custom reporters to Jest - * Custom reporters can be added to Jest using the reporters option in Jest - * Config. The format for adding a custom reporter is following - * - * "reporters": [ - * ["reporterPath/packageName", { option1: 'fasklj' }], - * // Format if we want to specify options - * "reporterName" - * // Format if we don't want to specify any options - * ] - * - * @private - * @param {ReporterConfig} reporters Array of reporters - * */ _addCustomReporters(reporters: ReporterConfig) { const customReporter = reporters.filter(reporter => reporter !== 'default'); customReporter.forEach((reporter, index) => { - const { - reporterPath, - reporterConfig = {}, - } = this._getReporterProps(reporter); + const {options, path} = this._getReporterProps(reporter); try { - const Reporter = require(reporterPath); - this.addReporter(new Reporter(reporterConfig)); + const Reporter = require(path); + this.addReporter(new Reporter(options)); } catch (error) { console.error( - 'An error occured while adding the reporter at path ' + reporterPath + 'An error occured while adding the reporter at path ' + path, ); throw error; } }); } + /** + * Get properties of a reporter in an object + * to make dealing with them less painful + * + * Objects contain the following properties: + * - options + * - path + */ + _getReporterProps(reporter: ReporterConfig) : Object { + if (typeof reporter === 'string') { + return {path: reporter}; + } else if (Array.isArray(reporter)) { + const [path, options] = reporter; + return {options, path}; + } + } + _bailIfNeeded(aggregatedResults: AggregatedResult, watcher: TestWatcher) { if (this._config.bail && aggregatedResults.numFailedTests !== 0) { if (watcher.isWatchMode()) { From 552d0e2dedf60406817e201be8bab92dcc79ff57 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Wed, 5 Apr 2017 01:23:39 +0500 Subject: [PATCH 42/59] make ReporterConfig type in types/Config simpler --- types/Config.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/types/Config.js b/types/Config.js index 20d896b5b6d4..f783ebcf196e 100644 --- a/types/Config.js +++ b/types/Config.js @@ -19,9 +19,7 @@ export type HasteConfig = {| providesModuleNodeModules: Array, |}; -export type SimpleReporter = string; -export type ComplexReporter = [string, Object]; -export type ReporterConfig = Array; +export type ReporterConfig = Array; export type ConfigGlobals = Object; @@ -93,7 +91,7 @@ export type Config = {| noStackTrace: boolean, notify: boolean, preset: ?string, - reporters: ReporterConfig, + reporters: Array, resetMocks: boolean, resetModules: boolean, resolver: ?Path, @@ -140,7 +138,7 @@ export type InitialConfig = {| forceExit?: boolean, globals?: ConfigGlobals, haste?: HasteConfig, - reporters?: ReporterConfig, + reporters?: Array, logHeapUsage?: boolean, logTransformErrors?: ?boolean, mapCoverage?: boolean, From 7d903c9c4a967c6884fe20f286b71c2d7b784c59 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Wed, 5 Apr 2017 02:26:39 +0500 Subject: [PATCH 43/59] remove comments --- packages/jest-cli/src/TestRunner.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index e3585eb081d5..ff579e278b81 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -31,6 +31,7 @@ const throat = require('throat'); const workerFarm = require('worker-farm'); const TestWatcher = require('./TestWatcher'); const ReporterDispatcher = require('./ReporterDispatcher'); +const chalk = require('chalk'); const DEFAULT_REPORTER_LABEL = 'default'; const SLOW_TEST_TIME = 3000; @@ -276,7 +277,7 @@ class TestRunner { * Checks if default reporters should be added or not * @private */ - _shouldAddDefaultReporters(reporters?: ReporterConfig): boolean { + _shouldAddDefaultReporters(reporters?: Array): boolean { return !reporters || reporters.indexOf(DEFAULT_REPORTER_LABEL) !== -1; } @@ -309,10 +310,6 @@ class TestRunner { } } - /** - * _ - * @param {config} Object Config object containing all the options - */ _setupDefaultReporters(config: Config) { this.addReporter( config.verbose ? new VerboseReporter(config) : new DefaultReporter(), @@ -323,6 +320,7 @@ class TestRunner { /** * Adds Custom reporters to Jest + * @private */ _addCustomReporters(reporters: ReporterConfig) { const customReporter = reporters.filter(reporter => reporter !== 'default'); @@ -335,7 +333,9 @@ class TestRunner { this.addReporter(new Reporter(options)); } catch (error) { console.error( - 'An error occured while adding the reporter at path ' + path, + chalk.red( + 'An error occured while adding the reporter at path' + path + ) ); throw error; } @@ -351,12 +351,15 @@ class TestRunner { * - path */ _getReporterProps(reporter: ReporterConfig) : Object { + let props = {}; if (typeof reporter === 'string') { - return {path: reporter}; + props = {path: reporter}; } else if (Array.isArray(reporter)) { const [path, options] = reporter; - return {options, path}; + props = {options, path}; } + + return props; } _bailIfNeeded(aggregatedResults: AggregatedResult, watcher: TestWatcher) { From 1aa5d54d1c79606fd3401ccf30212cfacca50895 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Wed, 5 Apr 2017 02:27:05 +0500 Subject: [PATCH 44/59] correct types and change method signatures --- .../src/reporterValidationErrors.js | 45 +++++++------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/packages/jest-config/src/reporterValidationErrors.js b/packages/jest-config/src/reporterValidationErrors.js index 2241a2ca02ce..3547787e02a6 100644 --- a/packages/jest-config/src/reporterValidationErrors.js +++ b/packages/jest-config/src/reporterValidationErrors.js @@ -21,60 +21,47 @@ const ERROR = `${BULLET} Reporter Validation Error`; * This is a highly specific reporter error and in the future will be * merged with jest-validate. Till then, we can make use of it. It works * and that's what counts most at this time - * - * @param {Number} reporterIndex specific index at which reporter is present - * @param {any} reporterValue value of the reporter, anything output by the user - * - * @returns {ValidationError} validation error which can be thrown if needed - * + */ function createReporterError( reporterIndex: number, reporterValue: any, ): ValidationError { - const errorMessage = `\tReporter at index ${reporterIndex} must be of type:\n` + + const errorMessage = ( + `Reporter at index ${reporterIndex} must be of type:\n` + `\t\t${chalk.bold.green(validReporterTypes.join(' or '))}\n` + `\tbut instead received:\n` + - `\t\t${chalk.bold.red(getType(reporterValue))}`; + `\t\t${chalk.bold.red(getType(reporterValue))}` + ); return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); } /** - * createArrayReporterError - * * Reporter Error specific to Array configuration - * - * @param {Number} reporterIndex index for the given reporter config - * @param {Number} valueIndex index of the - * @param {any} value value provided by the reporter - * @param {any} expected expected value for the reporter - * - * @returns {ValidationError} ValidationError */ function createArrayReporterError( reporterIndex: number, valueIndex: number, value: any, - expected: any, + expectedType: string, valueName: string, ): ValidationError { - const errorMessage = `\tUnexpected value for ${valueName} at index ${valueIndex} of reporter` + + const errorMessage = ( + `\tUnexpected value for ${valueName} at index ${valueIndex} of reporter` + `at index ${reporterIndex}\n` + '\tExpected:\n' + - `\t\t${chalk.bold.red(getType(expected))}\n` + + `\t\t${chalk.bold.red(expectedType)}\n` + '\tGot:\n' + `\t\t${chalk.bold.green(getType(value))}`; + ) return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); } /** - * valiates the each reporter within the reporters - * using appropriate values - * - * @param {Array} reporterConfig configuration for the given reporter - * @returns {boolean} true if all the given reporters are valid + * validates each reporter provided in the configuration + * @private */ function validateReporters(reporterConfig: Array): boolean { return reporterConfig.every((reporter, index) => { @@ -94,16 +81,18 @@ function validateReporters(reporterConfig: Array): boolean { * @param {Array} arrayReporter reporter to be validated * @returns {boolean} true if the reporter was validated */ -function validateArrayReporter(arrayReporter, reporterIndex) { +function validateArrayReporter( + arrayReporter: Array, reporterIndex: number +) { const [path, options] = arrayReporter; if (typeof path !== 'string') { - throw createArrayReporterError(reporterIndex, 0, path, '', 'Path'); + throw createArrayReporterError(reporterIndex, 0, path, 'string', 'Path'); } else if (typeof options !== 'object') { throw createArrayReporterError( reporterIndex, 1, options, - {}, + 'object', 'Reporter Configuration', ); } From 599c6ed27c49904385db27343ece4a887c3a8b71 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Wed, 5 Apr 2017 05:16:34 +0500 Subject: [PATCH 45/59] remove bug from reporterValidationErrors.js --- .../src/reporterValidationErrors.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/jest-config/src/reporterValidationErrors.js b/packages/jest-config/src/reporterValidationErrors.js index 3547787e02a6..e59ea8838391 100644 --- a/packages/jest-config/src/reporterValidationErrors.js +++ b/packages/jest-config/src/reporterValidationErrors.js @@ -21,18 +21,15 @@ const ERROR = `${BULLET} Reporter Validation Error`; * This is a highly specific reporter error and in the future will be * merged with jest-validate. Till then, we can make use of it. It works * and that's what counts most at this time - */ function createReporterError( reporterIndex: number, reporterValue: any, ): ValidationError { - const errorMessage = ( - `Reporter at index ${reporterIndex} must be of type:\n` + + const errorMessage = `Reporter at index ${reporterIndex} must be of type:\n` + `\t\t${chalk.bold.green(validReporterTypes.join(' or '))}\n` + `\tbut instead received:\n` + - `\t\t${chalk.bold.red(getType(reporterValue))}` - ); + `\t\t${chalk.bold.red(getType(reporterValue))}`; return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); } @@ -47,14 +44,12 @@ function createArrayReporterError( expectedType: string, valueName: string, ): ValidationError { - const errorMessage = ( - `\tUnexpected value for ${valueName} at index ${valueIndex} of reporter` + - `at index ${reporterIndex}\n` + + const errorMessage = `\tUnexpected value for ${valueName} at index ${valueIndex} of reporter` + + ` at index ${reporterIndex}\n` + '\tExpected:\n' + `\t\t${chalk.bold.red(expectedType)}\n` + '\tGot:\n' + `\t\t${chalk.bold.green(getType(value))}`; - ) return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); } @@ -66,7 +61,7 @@ function createArrayReporterError( function validateReporters(reporterConfig: Array): boolean { return reporterConfig.every((reporter, index) => { if (Array.isArray(reporter)) { - throw validateArrayReporter(reporter, index); + validateArrayReporter(reporter, index); } else if (typeof reporter !== 'string') { throw createReporterError(index, reporter); } @@ -82,7 +77,8 @@ function validateReporters(reporterConfig: Array): boolean { * @returns {boolean} true if the reporter was validated */ function validateArrayReporter( - arrayReporter: Array, reporterIndex: number + arrayReporter: Array, + reporterIndex: number, ) { const [path, options] = arrayReporter; if (typeof path !== 'string') { From b5aa966f2b7e7c1fb951ff6d542a78279d043f51 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Wed, 5 Apr 2017 05:17:57 +0500 Subject: [PATCH 46/59] make custom_reporters tests more concise --- .../custom-reporters-test.js.snap | 27 +++++++--- .../__tests__/custom-reporters-test.js | 54 +++---------------- .../__tests__/add-fail-test.js | 10 ++-- integration_tests/custom_reporters/add.js | 5 -- .../custom_reporters/package.json | 7 ++- 5 files changed, 39 insertions(+), 64 deletions(-) diff --git a/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap b/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap index 0ba353a19cef..5b28e62f43da 100644 --- a/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap +++ b/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap @@ -32,9 +32,9 @@ Object { "path": true, }, "options": Object { - "option1": "Hello", - "option2": "World", - "option3": "Amazing!!!", + "christop": "pojer", + "dmitrii": "abramov", + "hello": "world", }, } `; @@ -63,9 +63,24 @@ Object { "path": true, }, "options": Object { - "option1": "Hello", - "option2": "World", - "option3": "Amazing!!!", + "christop": "pojer", + "dmitrii": "abramov", + "hello": "world", }, } `; + +exports[`Custom Reporters Integration invalid format for adding reporters 1`] = ` +"● Reporter Validation Error: + + Unexpected value for Path at index 0 of reporter at index 0 + Expected: + string + Got: + number + + Configuration Documentation: + https://facebook.github.io/jest/docs/configuration.html + +" +`; diff --git a/integration_tests/__tests__/custom-reporters-test.js b/integration_tests/__tests__/custom-reporters-test.js index 3e1222fe15e8..4087f3f5cd53 100644 --- a/integration_tests/__tests__/custom-reporters-test.js +++ b/integration_tests/__tests__/custom-reporters-test.js @@ -16,13 +16,12 @@ describe('Custom Reporters Integration', () => { reporters: ['/reporters/TestReporter.js'], }; - const {status, stdout} = runJest('custom_reporters', [ + const {status} = runJest('custom_reporters', [ '--config', JSON.stringify(reporterConfig), 'add-test.js', ]); - console.log(stdout); expect(status).toBe(0); }); @@ -53,8 +52,8 @@ describe('Custom Reporters Integration', () => { 'add-test.js', ]); - expect(stderr).toMatch('Expected reporterPath for reporter'); expect(status).toBe(1); + expect(stderr).toMatchSnapshot(); }); test('TestReporter with all tests passing', () => { @@ -63,62 +62,29 @@ describe('Custom Reporters Integration', () => { status, stderr, } = runJest('custom_reporters', ['add-test.js']); - let parsedJSON; - - try { - parsedJSON = JSON.parse(stdout); - } catch (error) { - throw new Error('Failed to parse JSON, Check the Output of TestReporter'); - } - - const {onRunComplete, onRunStart, onTestResult, onTestStart} = parsedJSON; + const parsedJSON = JSON.parse(stdout); expect(status).toBe(0); - expect(stderr.trim()).toBeFalsy(); - - expect(onRunComplete.numPassedTests).toBe(1); - expect(onRunComplete.numFailedTests).toBe(0); - expect(onRunComplete.numTotalTests).toBe(1); - - expect(onRunStart.called).toBeTruthy(); - expect(onTestResult.called).toBeTruthy(); - expect(onTestStart.called).toBeTruthy(); - + expect(stderr.trim()).toBe(''); expect(parsedJSON).toMatchSnapshot(); }); test('TestReporter with all tests failing', () => { - let parsedJSON; const { stdout, status, stderr, } = runJest('custom_reporters', ['add-fail-test.js']); - try { - parsedJSON = JSON.parse(stdout); - } catch (error) { - throw new Error('Failed to parse JSON. Check the output of TestReporter'); - } - - const {onTestStart, onTestResult, onRunStart, onRunComplete} = parsedJSON; + const parsedJSON = JSON.parse(stdout); expect(status).toBe(1); - expect(stderr).toBeFalsy(); - - expect(onRunComplete.numPassedTests).toBe(0); - expect(onRunComplete.numFailedTests).toBe(1); - expect(onRunComplete.numTotalTests).toBe(1); - - expect(onRunStart.called).toBeTruthy(); - expect(onTestStart.called).toBeTruthy(); - expect(onTestResult.called).toBeTruthy(); - + expect(stderr.trim()).toBe(''); expect(parsedJSON).toMatchSnapshot(); }); test('IncompleteReporter for flexibility', () => { - const {stdout, status} = runJest('custom_reporters', [ + const {stderr, stdout, status} = runJest('custom_reporters', [ '--config', JSON.stringify({ reporters: ['/reporters/IncompleteReporter.js'], @@ -127,11 +93,7 @@ describe('Custom Reporters Integration', () => { ]); expect(status).toBe(0); - - expect(stdout).toMatch('onRunComplete is called'); - expect(stdout).toMatch('Passed Tests: 1'); - expect(stdout).toMatch('Failed Tests: 0'); - expect(stdout).toMatch('Total Tests: 1'); + expect(stderr.trim()).toBe(''); expect(stdout).toMatchSnapshot(); }); diff --git a/integration_tests/custom_reporters/__tests__/add-fail-test.js b/integration_tests/custom_reporters/__tests__/add-fail-test.js index e81456dbcad3..ece775e4041b 100644 --- a/integration_tests/custom_reporters/__tests__/add-fail-test.js +++ b/integration_tests/custom_reporters/__tests__/add-fail-test.js @@ -1,9 +1,9 @@ const add = require('../add'); describe('CustomReporters', () => { - test('adds fail', () => { - expect(add(1, 3)).toBe(231); - expect(add(5, 7)).toBe(120); - expect(add(2, 4)).toBe(6); - }); + test('adds fail', () => { + expect(add(1, 3)).toBe(231); + expect(add(5, 7)).toBe(120); + expect(add(2, 4)).toBe(6); + }); }); diff --git a/integration_tests/custom_reporters/add.js b/integration_tests/custom_reporters/add.js index 4250ae2ea601..a0c0708e2f9c 100644 --- a/integration_tests/custom_reporters/add.js +++ b/integration_tests/custom_reporters/add.js @@ -1,8 +1,3 @@ -/** - * add - * @param {Number} x - * @param {Number} y - */ module.exports = function add(x, y) { return x + y; }; diff --git a/integration_tests/custom_reporters/package.json b/integration_tests/custom_reporters/package.json index 43d4441b363a..6fa9b322698e 100644 --- a/integration_tests/custom_reporters/package.json +++ b/integration_tests/custom_reporters/package.json @@ -1,8 +1,11 @@ { "jest": { "reporters": [ - 132231332, - ["akljda", 2121] + ["/reporters/TestReporter.js", { + "hello": "world", + "dmitrii": "abramov", + "christop": "pojer" + }] ] } } From d1cf92e9f15fc81e5d769e700a7db4db3ce4e15f Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Wed, 5 Apr 2017 05:36:49 +0500 Subject: [PATCH 47/59] fix lint error in website this error is not letting me lint 100% safe --- website/core/center.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/core/center.js b/website/core/center.js index 02265efd9027..e8d03a10c6df 100644 --- a/website/core/center.js +++ b/website/core/center.js @@ -9,11 +9,11 @@ const assign = require('object-assign'); const center = React.createClass({ render() { - let {style, ...props} = this.props; - style = assign({}, style, {textAlign: 'center'}); + const {style, ...props} = this.props; + const newStyle = assign({}, style, {textAlign: 'center'}); return ( -
{this.props.children}
+
{this.props.children}
); }, }); From 23a7610fe90424705a21e1be9cefa3cd452a9d83 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Wed, 5 Apr 2017 05:39:13 +0500 Subject: [PATCH 48/59] finalize types for reporters --- types/Config.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/Config.js b/types/Config.js index f783ebcf196e..d1392e629402 100644 --- a/types/Config.js +++ b/types/Config.js @@ -19,7 +19,9 @@ export type HasteConfig = {| providesModuleNodeModules: Array, |}; -export type ReporterConfig = Array; +export type ReporterConfig = StringReporter | ArrayReporter; +export type StringReporter = string; +export type ArrayReporter = [string, Object]; export type ConfigGlobals = Object; From dd2d6525cc07181a7c0e201709502f67d61b0467 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Wed, 5 Apr 2017 05:39:29 +0500 Subject: [PATCH 49/59] yarn prettier --- packages/jest-cli/src/TestRunner.js | 10 +++++----- packages/jest-jasmine2/src/treeProcessor.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/TestRunner.js index ff579e278b81..7aca55c39d34 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/TestRunner.js @@ -287,7 +287,7 @@ class TestRunner { */ _setupReporters() { const config = this._config; - const {reporters} = config; + const reporters = config.reporters; const isDefault: boolean = this._shouldAddDefaultReporters(reporters); if (isDefault) { @@ -322,7 +322,7 @@ class TestRunner { * Adds Custom reporters to Jest * @private */ - _addCustomReporters(reporters: ReporterConfig) { + _addCustomReporters(reporters: Array) { const customReporter = reporters.filter(reporter => reporter !== 'default'); customReporter.forEach((reporter, index) => { @@ -334,8 +334,8 @@ class TestRunner { } catch (error) { console.error( chalk.red( - 'An error occured while adding the reporter at path' + path - ) + 'An error occured while adding the reporter at path ' + path, + ), ); throw error; } @@ -350,7 +350,7 @@ class TestRunner { * - options * - path */ - _getReporterProps(reporter: ReporterConfig) : Object { + _getReporterProps(reporter: ReporterConfig): Object { let props = {}; if (typeof reporter === 'string') { props = {path: reporter}; diff --git a/packages/jest-jasmine2/src/treeProcessor.js b/packages/jest-jasmine2/src/treeProcessor.js index 5eb55c0460f9..3b27cc99374e 100644 --- a/packages/jest-jasmine2/src/treeProcessor.js +++ b/packages/jest-jasmine2/src/treeProcessor.js @@ -41,7 +41,7 @@ function treeProcessor(options: Options) { } return queueRunnerFactory({ - onException: error => tree.onException(tree, error), + onException: error => tree.onException(error), queueableFns: wrapChildren(tree, isEnabled(tree, false)), userContext: tree.sharedUserContext(), }); @@ -59,7 +59,7 @@ function treeProcessor(options: Options) { async fn(done) { nodeStart(node); await queueRunnerFactory({ - onException: error => node.onException(node, error), + onException: error => node.onException(error), queueableFns: wrapChildren(node, enabled), userContext: node.sharedUserContext(), }); From 33640bed46173318d8892ccdde58a1038dce24c9 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Wed, 5 Apr 2017 05:48:45 +0500 Subject: [PATCH 50/59] remove .vscode folder --- .vscode/settings.json | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 7bdc4685281f..000000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "jest.pathToJest": "npm run jest --", - "editor.rulers": [ - 80 -], -"eslint.enable": true, -"javascript.validate.enable": false -} From 937a3c950e0e75b905d60f2901179aad9cd7011e Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Wed, 5 Apr 2017 05:49:24 +0500 Subject: [PATCH 51/59] all integration_tests are prettier now --- .../coverage_report/not-required-in-test-suite.js | 2 +- integration_tests/custom_reporters/add.js | 2 +- .../custom_reporters/reporters/TestReporter.js | 4 ++-- .../jasmine_async/__tests__/promise_beforeAll-test.js | 4 ++-- .../jasmine_async/__tests__/promise_it-test.js | 6 +++--- integration_tests/snapshot/__tests__/snapshot-test.js | 2 +- .../typescript-coverage/typescript-preprocessor.js | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/integration_tests/coverage_report/not-required-in-test-suite.js b/integration_tests/coverage_report/not-required-in-test-suite.js index c3ce8bb48301..747a45c65575 100644 --- a/integration_tests/coverage_report/not-required-in-test-suite.js +++ b/integration_tests/coverage_report/not-required-in-test-suite.js @@ -9,7 +9,7 @@ throw new Error( `this error should not be a problem because` + - `this file is never required or executed` + `this file is never required or executed`, ); // Flow annotations to make sure istanbul can instrument non ES6 source diff --git a/integration_tests/custom_reporters/add.js b/integration_tests/custom_reporters/add.js index a0c0708e2f9c..a7276b3dd0a9 100644 --- a/integration_tests/custom_reporters/add.js +++ b/integration_tests/custom_reporters/add.js @@ -1,3 +1,3 @@ module.exports = function add(x, y) { - return x + y; + return x + y; }; diff --git a/integration_tests/custom_reporters/reporters/TestReporter.js b/integration_tests/custom_reporters/reporters/TestReporter.js index 678d64c4fdad..36235614f35a 100644 --- a/integration_tests/custom_reporters/reporters/TestReporter.js +++ b/integration_tests/custom_reporters/reporters/TestReporter.js @@ -72,10 +72,10 @@ class TestReporter { onRunComplete.called = true; onRunComplete.config = typeof config; - + onRunComplete.numPassedTests = results.numPassedTests; onRunComplete.numFailedTests = results.numFailedTests; - onRunComplete.numTotalTests = results.numTotalTests; + onRunComplete.numTotalTests = results.numTotalTests; // The Final Call process.stdout.write(JSON.stringify(this._statsCollected, null, 4)); diff --git a/integration_tests/jasmine_async/__tests__/promise_beforeAll-test.js b/integration_tests/jasmine_async/__tests__/promise_beforeAll-test.js index 0f7204947611..33135bd76cd9 100644 --- a/integration_tests/jasmine_async/__tests__/promise_beforeAll-test.js +++ b/integration_tests/jasmine_async/__tests__/promise_beforeAll-test.js @@ -21,7 +21,7 @@ describe('promise beforeAll', () => { () => { return new Promise(resolve => setTimeout(resolve, 10)); }, - 500 + 500, ); // passing tests @@ -35,7 +35,7 @@ describe('promise beforeAll', () => { () => { return new Promise(resolve => setTimeout(resolve, 100)); }, - 10 + 10, ); it('fails', () => {}); diff --git a/integration_tests/jasmine_async/__tests__/promise_it-test.js b/integration_tests/jasmine_async/__tests__/promise_it-test.js index 8b67dd95be37..7592e0942f62 100644 --- a/integration_tests/jasmine_async/__tests__/promise_it-test.js +++ b/integration_tests/jasmine_async/__tests__/promise_it-test.js @@ -30,7 +30,7 @@ describe('promise it', () => { return new Promise(resolve => { if (this.someContextValue !== 'value') { throw new Error( - 'expected this.someContextValue to be set: ' + this.someContextValue + 'expected this.someContextValue to be set: ' + this.someContextValue, ); } resolve(); @@ -55,7 +55,7 @@ describe('promise it', () => { () => { return new Promise(resolve => setTimeout(resolve, 10)); }, - 250 + 250, ); // failing tests @@ -64,6 +64,6 @@ describe('promise it', () => { () => { return new Promise(resolve => setTimeout(resolve, 100)); }, - 10 + 10, ); }); diff --git a/integration_tests/snapshot/__tests__/snapshot-test.js b/integration_tests/snapshot/__tests__/snapshot-test.js index 9013126e166c..a4e02cec723b 100644 --- a/integration_tests/snapshot/__tests__/snapshot-test.js +++ b/integration_tests/snapshot/__tests__/snapshot-test.js @@ -32,7 +32,7 @@ describe('snapshot', () => { it('cannot be used with .not', () => { expect(() => expect('').not.toMatchSnapshot()).toThrow( - 'Jest: `.not` cannot be used with `.toMatchSnapshot()`.' + 'Jest: `.not` cannot be used with `.toMatchSnapshot()`.', ); }); diff --git a/integration_tests/typescript-coverage/typescript-preprocessor.js b/integration_tests/typescript-coverage/typescript-preprocessor.js index 925928d07763..3e87902642ff 100644 --- a/integration_tests/typescript-coverage/typescript-preprocessor.js +++ b/integration_tests/typescript-coverage/typescript-preprocessor.js @@ -12,7 +12,7 @@ module.exports = { module: tsc.ModuleKind.CommonJS, }, path, - [] + [], ); } return src; From 492e0debc4126cdbe4ec7c05d30a61cde0c860d4 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Wed, 5 Apr 2017 06:44:40 +0500 Subject: [PATCH 52/59] remove validateReporters call --- .../__tests__/promise_beforeAll-test.js | 4 +- .../__tests__/promise_it-test.js | 6 +- .../snapshot/__tests__/snapshot-test.js | 2 +- .../typescript-preprocessor.js | 2 +- packages/jest-cli/src/ReporterDispatcher.js | 28 +- yarn.lock | 452 +++++++++--------- 6 files changed, 234 insertions(+), 260 deletions(-) diff --git a/integration_tests/jasmine_async/__tests__/promise_beforeAll-test.js b/integration_tests/jasmine_async/__tests__/promise_beforeAll-test.js index 33135bd76cd9..0f7204947611 100644 --- a/integration_tests/jasmine_async/__tests__/promise_beforeAll-test.js +++ b/integration_tests/jasmine_async/__tests__/promise_beforeAll-test.js @@ -21,7 +21,7 @@ describe('promise beforeAll', () => { () => { return new Promise(resolve => setTimeout(resolve, 10)); }, - 500, + 500 ); // passing tests @@ -35,7 +35,7 @@ describe('promise beforeAll', () => { () => { return new Promise(resolve => setTimeout(resolve, 100)); }, - 10, + 10 ); it('fails', () => {}); diff --git a/integration_tests/jasmine_async/__tests__/promise_it-test.js b/integration_tests/jasmine_async/__tests__/promise_it-test.js index 7592e0942f62..8b67dd95be37 100644 --- a/integration_tests/jasmine_async/__tests__/promise_it-test.js +++ b/integration_tests/jasmine_async/__tests__/promise_it-test.js @@ -30,7 +30,7 @@ describe('promise it', () => { return new Promise(resolve => { if (this.someContextValue !== 'value') { throw new Error( - 'expected this.someContextValue to be set: ' + this.someContextValue, + 'expected this.someContextValue to be set: ' + this.someContextValue ); } resolve(); @@ -55,7 +55,7 @@ describe('promise it', () => { () => { return new Promise(resolve => setTimeout(resolve, 10)); }, - 250, + 250 ); // failing tests @@ -64,6 +64,6 @@ describe('promise it', () => { () => { return new Promise(resolve => setTimeout(resolve, 100)); }, - 10, + 10 ); }); diff --git a/integration_tests/snapshot/__tests__/snapshot-test.js b/integration_tests/snapshot/__tests__/snapshot-test.js index a4e02cec723b..9013126e166c 100644 --- a/integration_tests/snapshot/__tests__/snapshot-test.js +++ b/integration_tests/snapshot/__tests__/snapshot-test.js @@ -32,7 +32,7 @@ describe('snapshot', () => { it('cannot be used with .not', () => { expect(() => expect('').not.toMatchSnapshot()).toThrow( - 'Jest: `.not` cannot be used with `.toMatchSnapshot()`.', + 'Jest: `.not` cannot be used with `.toMatchSnapshot()`.' ); }); diff --git a/integration_tests/typescript-coverage/typescript-preprocessor.js b/integration_tests/typescript-coverage/typescript-preprocessor.js index 3e87902642ff..925928d07763 100644 --- a/integration_tests/typescript-coverage/typescript-preprocessor.js +++ b/integration_tests/typescript-coverage/typescript-preprocessor.js @@ -12,7 +12,7 @@ module.exports = { module: tsc.ModuleKind.CommonJS, }, path, - [], + [] ); } return src; diff --git a/packages/jest-cli/src/ReporterDispatcher.js b/packages/jest-cli/src/ReporterDispatcher.js index e034c6fcfabf..69d33f0fc034 100644 --- a/packages/jest-cli/src/ReporterDispatcher.js +++ b/packages/jest-cli/src/ReporterDispatcher.js @@ -29,14 +29,10 @@ class ReporterDispatcher { constructor(hasteFS: HasteFS, getTestSummary: () => string) { this._runnerContext = {getTestSummary, hasteFS}; this._reporters = []; - - this._requiredMethods = []; } register(reporter: Object): void { - if (this._validateReporter(reporter)) { - this._reporters.push(reporter); - } + this._reporters.push(reporter); } unregister(ReporterClass: Function): void { @@ -99,28 +95,6 @@ class ReporterDispatcher { }); } - /** - * _validateReporter - * Validates the reporters to be added by checking for the required - * methods - * - * @private - * @param {Object} reporter reporter to be validated - * @returns {boolean} returns true if the reporter is validated - */ - _validateReporter(reporter: Object) { - return this._requiredMethods.every(method => { - if (typeof reporter[method] !== 'function') { - throw new Error( - `Given method '${method}' does not exist on the reporter: ` + - reporter.name, - ); - } - - return true; - }); - } - // Return a list of last errors for every reporter getErrors(): Array { return this._reporters.reduce( diff --git a/yarn.lock b/yarn.lock index 8fc44f9d3f79..6c28facd05d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18,10 +18,6 @@ acorn-jsx@^3.0.0: dependencies: acorn "^3.0.4" -acorn@4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.4.tgz#17a8d6a7a6c4ef538b814ec9abac2779293bf30a" - acorn@^3.0.4: version "3.3.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" @@ -30,13 +26,17 @@ acorn@^4.0.4: version "4.0.11" resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.11.tgz#edcda3bd937e7556410d42ed5860f67399c794c0" +acorn@^5.0.1: + version "5.0.3" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.0.3.tgz#c460df08491463f028ccb82eab3730bf01087b3d" + ajv-keywords@^1.0.0: version "1.5.1" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" ajv@^4.7.0, ajv@^4.9.1: - version "4.11.3" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.3.tgz#ce30bdb90d1254f762c75af915fb3a63e7183d22" + version "4.11.5" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.5.tgz#b6ee74657b993a01dce44b7944d56f485828d5bd" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" @@ -120,8 +120,8 @@ array-unique@^0.2.1: resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" array.prototype.find@^2.0.1: - version "2.0.3" - resolved "https://registry.yarnpkg.com/array.prototype.find/-/array.prototype.find-2.0.3.tgz#08c3ec33e32ec4bab362a2958e686ae92f59271d" + version "2.0.4" + resolved "https://registry.yarnpkg.com/array.prototype.find/-/array.prototype.find-2.0.4.tgz#556a5c5362c08648323ddaeb9de9d14bc1864c90" dependencies: define-properties "^1.1.2" es-abstract "^1.7.0" @@ -138,14 +138,14 @@ asn1@~0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + assert-plus@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" -assert-plus@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" - ast-types@0.8.18: version "0.8.18" resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.8.18.tgz#c8b98574898e8914e9d8de74b947564a9fe929af" @@ -154,20 +154,16 @@ ast-types@0.9.4: version "0.9.4" resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.4.tgz#410d1f81890aeb8e0a38621558ba5869ae53c91b" -async@^1.4.0, async@^1.4.2, async@^1.5.0: +async@^1.4.0, async@^1.5.0: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" async@^2.1.4: - version "2.1.5" - resolved "https://registry.yarnpkg.com/async/-/async-2.1.5.tgz#e587c68580994ac67fc56ff86d3ac56bdbe810bc" + version "2.3.0" + resolved "https://registry.yarnpkg.com/async/-/async-2.3.0.tgz#1013d1051047dd320fe24e494d5c66ecaf6147d9" dependencies: lodash "^4.14.0" -async@~0.2.6: - version "0.2.10" - resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" - asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -188,15 +184,15 @@ babel-code-frame@6.22.0, babel-code-frame@^6.16.0, babel-code-frame@^6.22.0: esutils "^2.0.2" js-tokens "^3.0.0" -babel-core@^6.23.0, babel-core@^6.23.1: - version "6.23.1" - resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.23.1.tgz#c143cb621bb2f621710c220c5d579d15b8a442df" +babel-core@^6.23.1, babel-core@^6.24.0: + version "6.24.0" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.24.0.tgz#8f36a0a77f5c155aed6f920b844d23ba56742a02" dependencies: babel-code-frame "^6.22.0" - babel-generator "^6.23.0" + babel-generator "^6.24.0" babel-helpers "^6.23.0" babel-messages "^6.23.0" - babel-register "^6.23.0" + babel-register "^6.24.0" babel-runtime "^6.22.0" babel-template "^6.23.0" babel-traverse "^6.23.1" @@ -213,18 +209,17 @@ babel-core@^6.23.0, babel-core@^6.23.1: source-map "^0.5.0" babel-eslint@^7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-7.1.1.tgz#8a6a884f085aa7060af69cfc77341c2f99370fb2" + version "7.2.1" + resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-7.2.1.tgz#079422eb73ba811e3ca0865ce87af29327f8c52f" dependencies: - babel-code-frame "^6.16.0" - babel-traverse "^6.15.0" - babel-types "^6.15.0" - babylon "^6.13.0" - lodash.pickby "^4.6.0" + babel-code-frame "^6.22.0" + babel-traverse "^6.23.1" + babel-types "^6.23.0" + babylon "^6.16.1" -babel-generator@^6.18.0, babel-generator@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.23.0.tgz#6b8edab956ef3116f79d8c84c5a3c05f32a74bc5" +babel-generator@^6.18.0, babel-generator@^6.24.0: + version "6.24.0" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.24.0.tgz#eba270a8cc4ce6e09a61be43465d7c62c1f87c56" dependencies: babel-messages "^6.23.0" babel-runtime "^6.22.0" @@ -335,11 +330,11 @@ babel-plugin-transform-flow-strip-types@^6.18.0: babel-plugin-syntax-flow "^6.18.0" babel-runtime "^6.22.0" -babel-register@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.23.0.tgz#c9aa3d4cca94b51da34826c4a0f9e08145d74ff3" +babel-register@^6.24.0: + version "6.24.0" + resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.24.0.tgz#5e89f8463ba9970356d02eb07dabe3308b080cfd" dependencies: - babel-core "^6.23.0" + babel-core "^6.24.0" babel-runtime "^6.22.0" core-js "^2.4.0" home-or-tmp "^2.0.0" @@ -364,7 +359,7 @@ babel-template@^6.16.0, babel-template@^6.22.0, babel-template@^6.23.0: babylon "^6.11.0" lodash "^4.2.0" -babel-traverse@^6.15.0, babel-traverse@^6.18.0, babel-traverse@^6.22.0, babel-traverse@^6.23.0, babel-traverse@^6.23.1: +babel-traverse@^6.18.0, babel-traverse@^6.22.0, babel-traverse@^6.23.0, babel-traverse@^6.23.1: version "6.23.1" resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.23.1.tgz#d3cb59010ecd06a97d81310065f966b699e14f48" dependencies: @@ -378,7 +373,7 @@ babel-traverse@^6.15.0, babel-traverse@^6.18.0, babel-traverse@^6.22.0, babel-tr invariant "^2.2.0" lodash "^4.2.0" -babel-types@^6.15.0, babel-types@^6.18.0, babel-types@^6.22.0, babel-types@^6.23.0: +babel-types@^6.18.0, babel-types@^6.22.0, babel-types@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.23.0.tgz#bb17179d7538bad38cd0c9e115d340f77e7e9acf" dependencies: @@ -391,7 +386,7 @@ babylon@6.15.0: version "6.15.0" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e" -babylon@^6.11.0, babylon@^6.13.0, babylon@^6.15.0: +babylon@^6.11.0, babylon@^6.13.0, babylon@^6.15.0, babylon@^6.16.1: version "6.16.1" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3" @@ -571,8 +566,8 @@ color-convert@^1.0.0: color-name "^1.1.1" color-name@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.1.tgz#4b1415304cf50028ea81643643bd82ea05803689" + version "1.1.2" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.2.tgz#5c8ab72b64bd2215d617ae9559ebb148475cf98d" colors@>=0.6.2: version "1.1.2" @@ -599,7 +594,7 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concat-stream@^1.4.6: +concat-stream@^1.5.2: version "1.6.0" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" dependencies: @@ -612,8 +607,8 @@ content-type-parser@^1.0.1: resolved "https://registry.yarnpkg.com/content-type-parser/-/content-type-parser-1.0.1.tgz#c3e56988c53c65127fb46d4032a3a900246fdc94" convert-source-map@^1.1.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.4.0.tgz#e3dad195bf61bfe13a7a3c73e9876ec14a0268f3" + version "1.5.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5" core-js@^1.0.0: version "1.2.7" @@ -664,11 +659,11 @@ currently-unhandled@^0.4.1: dependencies: array-find-index "^1.0.1" -d@^0.1.1, d@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/d/-/d-0.1.1.tgz#da184c535d18d8ee7ba2aa229b914009fae11309" +d@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f" dependencies: - es5-ext "~0.10.2" + es5-ext "^0.10.9" dashdash@^1.12.0: version "1.14.1" @@ -677,8 +672,8 @@ dashdash@^1.12.0: assert-plus "^1.0.0" debug@^2.1.1, debug@^2.2.0: - version "2.6.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.1.tgz#79855090ba2c4e3115cc7d8769491d58f0491351" + version "2.6.3" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.3.tgz#0f7eb8c30965ec08c72accfa0130c8b79984141d" dependencies: ms "0.7.2" @@ -738,6 +733,13 @@ doctrine@^1.2.2: esutils "^2.0.2" isarray "^1.0.0" +doctrine@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.0.tgz#c73d8d2909d22291e1a007a395804da8b665fe63" + dependencies: + esutils "^2.0.2" + isarray "^1.0.0" + ecc-jsbn@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" @@ -773,57 +775,57 @@ es-to-primitive@^1.1.1: is-date-object "^1.0.1" is-symbol "^1.0.1" -es5-ext@^0.10.7, es5-ext@^0.10.8, es5-ext@~0.10.11, es5-ext@~0.10.2, es5-ext@~0.10.7: - version "0.10.12" - resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.12.tgz#aa84641d4db76b62abba5e45fd805ecbab140047" +es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.14: + version "0.10.15" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.15.tgz#c330a5934c1ee21284a7c081a86e5fd937c91ea6" dependencies: es6-iterator "2" es6-symbol "~3.1" -es6-iterator@2: - version "2.0.0" - resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.0.tgz#bd968567d61635e33c0b80727613c9cb4b096bac" +es6-iterator@2, es6-iterator@^2.0.1, es6-iterator@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.1.tgz#8e319c9f0453bf575d374940a655920e59ca5512" dependencies: - d "^0.1.1" - es5-ext "^0.10.7" - es6-symbol "3" + d "1" + es5-ext "^0.10.14" + es6-symbol "^3.1" es6-map@^0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/es6-map/-/es6-map-0.1.4.tgz#a34b147be224773a4d7da8072794cefa3632b897" + version "0.1.5" + resolved "https://registry.yarnpkg.com/es6-map/-/es6-map-0.1.5.tgz#9136e0503dcc06a301690f0bb14ff4e364e949f0" dependencies: - d "~0.1.1" - es5-ext "~0.10.11" - es6-iterator "2" - es6-set "~0.1.3" - es6-symbol "~3.1.0" - event-emitter "~0.3.4" + d "1" + es5-ext "~0.10.14" + es6-iterator "~2.0.1" + es6-set "~0.1.5" + es6-symbol "~3.1.1" + event-emitter "~0.3.5" -es6-set@~0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.4.tgz#9516b6761c2964b92ff479456233a247dc707ce8" +es6-set@~0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1" dependencies: - d "~0.1.1" - es5-ext "~0.10.11" - es6-iterator "2" - es6-symbol "3" - event-emitter "~0.3.4" + d "1" + es5-ext "~0.10.14" + es6-iterator "~2.0.1" + es6-symbol "3.1.1" + event-emitter "~0.3.5" -es6-symbol@3, es6-symbol@~3.1, es6-symbol@~3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.0.tgz#94481c655e7a7cad82eba832d97d5433496d7ffa" +es6-symbol@3.1.1, es6-symbol@^3.1, es6-symbol@^3.1.1, es6-symbol@~3.1, es6-symbol@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" dependencies: - d "~0.1.1" - es5-ext "~0.10.11" + d "1" + es5-ext "~0.10.14" es6-weak-map@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.1.tgz#0d2bbd8827eb5fb4ba8f97fbfea50d43db21ea81" + version "2.0.2" + resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f" dependencies: - d "^0.1.1" - es5-ext "^0.10.8" - es6-iterator "2" - es6-symbol "3" + d "1" + es5-ext "^0.10.14" + es6-iterator "^2.0.1" + es6-symbol "^3.1.1" escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" @@ -854,8 +856,8 @@ eslint-plugin-babel@^4.1.1: resolved "https://registry.yarnpkg.com/eslint-plugin-babel/-/eslint-plugin-babel-4.1.1.tgz#ef285c87039b67beb3bbd227f5b0eed4fb376b87" eslint-plugin-flowtype@^2.30.3: - version "2.30.3" - resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.30.3.tgz#57835d2c0ed388da7a2725803ec32af2f437c301" + version "2.30.4" + resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.30.4.tgz#771d6bb4578ab8598e9c58018fea2e1a22946249" dependencies: lodash "^4.15.0" @@ -868,8 +870,8 @@ eslint-plugin-markdown@^1.0.0-beta.4: remark "^5.0.0" eslint-plugin-react@^6.7.1: - version "6.10.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-6.10.0.tgz#9c48b48d101554b5355413e7c64238abde6ef1ef" + version "6.10.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-6.10.3.tgz#c5435beb06774e12c7db2f6abaddcbf900cd3f78" dependencies: array.prototype.find "^2.0.1" doctrine "^1.2.2" @@ -878,16 +880,17 @@ eslint-plugin-react@^6.7.1: object.assign "^4.0.4" eslint@^3.17.1: - version "3.17.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.17.1.tgz#b80ae12d9c406d858406fccda627afce33ea10ea" + version "3.19.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.19.0.tgz#c8fc6201c7f40dd08941b87c085767386a679acc" dependencies: babel-code-frame "^6.16.0" chalk "^1.1.3" - concat-stream "^1.4.6" + concat-stream "^1.5.2" debug "^2.1.1" - doctrine "^1.2.2" + doctrine "^2.0.0" escope "^3.6.0" espree "^3.4.0" + esquery "^1.0.0" estraverse "^4.2.0" esutils "^2.0.2" file-entry-cache "^2.0.0" @@ -917,10 +920,10 @@ eslint@^3.17.1: user-home "^2.0.0" espree@^3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.4.0.tgz#41656fa5628e042878025ef467e78f125cb86e1d" + version "3.4.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.4.1.tgz#28a83ab4aaed71ed8fe0f5efe61b76a05c13c4d2" dependencies: - acorn "4.0.4" + acorn "^5.0.1" acorn-jsx "^3.0.0" esprima@^2.7.1: @@ -931,6 +934,12 @@ esprima@^3.1.1: version "3.1.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" +esquery@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.0.tgz#cfba8b57d7fba93f17298a8a006a04cda13d80fa" + dependencies: + estraverse "^4.0.0" + esrecurse@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.1.0.tgz#4713b6536adf7f2ac4f327d559e7756bff648220" @@ -942,7 +951,7 @@ estraverse@^1.9.1: version "1.9.3" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44" -estraverse@^4.1.1, estraverse@^4.2.0: +estraverse@^4.0.0, estraverse@^4.1.1, estraverse@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" @@ -954,12 +963,12 @@ esutils@2.0.2, esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" -event-emitter@~0.3.4: - version "0.3.4" - resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.4.tgz#8d63ddfb4cfe1fae3b32ca265c4c720222080bb5" +event-emitter@~0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" dependencies: - d "~0.1.1" - es5-ext "~0.10.7" + d "1" + es5-ext "~0.10.14" execSync@1.0.2: version "1.0.2" @@ -971,10 +980,6 @@ exit-hook@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" -exit@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" - expand-brackets@^0.1.4: version "0.1.5" resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" @@ -1012,8 +1017,8 @@ fast-levenshtein@~2.0.4: resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" fbjs@^0.8.4: - version "0.8.9" - resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.9.tgz#180247fbd347dcc9004517b904f865400a0c8f14" + version "0.8.12" + resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.12.tgz#10b5d92f76d45575fd63a217d4ea02bea2f8ed04" dependencies: core-js "^1.0.0" isomorphic-fetch "^2.1.1" @@ -1175,8 +1180,8 @@ glob@7.1.1, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1: path-is-absolute "^1.0.0" globals@^9.0.0, globals@^9.14.0: - version "9.16.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-9.16.0.tgz#63e903658171ec2d9f51b1d31de5e2b8dc01fb80" + version "9.17.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-9.17.0.tgz#0c0ca696d9b9bb694d2e5470bd37777caad50286" globby@^5.0.0: version "5.0.0" @@ -1211,9 +1216,9 @@ har-schema@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" -har-validator@~4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.0.tgz#c2efa9f6c50fee92ef033cf30b796a2c5b660cd7" +har-validator@~4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" dependencies: ajv "^4.9.1" har-schema "^1.0.5" @@ -1255,8 +1260,8 @@ home-or-tmp@^2.0.0: os-tmpdir "^1.0.1" hosted-git-info@^2.1.4: - version "2.2.0" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.2.0.tgz#7a0d097863d886c0fabbdcd37bf1758d8becf8a5" + version "2.4.1" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.4.1.tgz#4b0445e41c004a8bd1337773a4ff790ca40318c8" html-encoding-sniffer@^1.0.1: version "1.0.1" @@ -1277,12 +1282,12 @@ iconv-lite@0.4.13, iconv-lite@~0.4.13: resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2" ignore@^3.2.0: - version "3.2.4" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.2.4.tgz#4055e03596729a8fabe45a43c100ad5ed815c4e8" + version "3.2.6" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.2.6.tgz#26e8da0644be0bb4cb39516f6c79f0e0f4ffe48c" immutable@^4.0.0-rc.1: - version "4.0.0-rc.1" - resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.0.0-rc.1.tgz#75c5d728ccf1fb22d0a459add6748448ae270acc" + version "4.0.0-rc.2" + resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.0.0-rc.2.tgz#fdd0948aae728fda2306a02f72bb73e1773432d1" imurmurhash@^0.1.4: version "0.1.4" @@ -1342,8 +1347,8 @@ inquirer@^3.0.1: through "^2.3.6" interpret@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c" + version "1.0.2" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.2.tgz#f4f623f0bb7122f15f5717c8e254b8161b5c5b2d" invariant@^2.2.0: version "2.2.2" @@ -1367,8 +1372,8 @@ is-arrayish@^0.2.1: resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" is-buffer@^1.0.2: - version "1.1.4" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.4.tgz#cfc86ccd5dc5a52fa80489111c6920c457e2d98b" + version "1.1.5" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" is-builtin-module@^1.0.0: version "1.0.0" @@ -1511,9 +1516,9 @@ isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" -isexe@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-1.1.2.tgz#36f3e22e60750920f5e7241a476a8c6a42275ad0" +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" isobject@^2.0.0: version "2.1.0" @@ -1533,89 +1538,74 @@ isstream@~0.1.2: resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" istanbul-api@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.1.1.tgz#d36e2f1560d1a43ce304c4ff7338182de61c8f73" + version "1.1.7" + resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.1.7.tgz#f6f37f09f8002b130f891c646b70ee4a8e7345ae" dependencies: async "^2.1.4" fileset "^2.0.2" - istanbul-lib-coverage "^1.0.0" - istanbul-lib-hook "^1.0.0" - istanbul-lib-instrument "^1.3.0" - istanbul-lib-report "^1.0.0-alpha.3" - istanbul-lib-source-maps "^1.1.0" - istanbul-reports "^1.0.0" + istanbul-lib-coverage "^1.0.2" + istanbul-lib-hook "^1.0.5" + istanbul-lib-instrument "^1.7.0" + istanbul-lib-report "^1.0.0" + istanbul-lib-source-maps "^1.1.1" + istanbul-reports "^1.0.2" js-yaml "^3.7.0" mkdirp "^0.5.1" once "^1.4.0" -istanbul-lib-coverage@^1.0.0, istanbul-lib-coverage@^1.0.0-alpha, istanbul-lib-coverage@^1.0.0-alpha.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.1.tgz#f263efb519c051c5f1f3343034fc40e7b43ff212" +istanbul-lib-coverage@^1.0.0, istanbul-lib-coverage@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.2.tgz#87a0c015b6910651cb3b184814dfb339337e25e1" -istanbul-lib-hook@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.0.0.tgz#fc5367ee27f59268e8f060b0c7aaf051d9c425c5" +istanbul-lib-hook@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.0.5.tgz#6ca3d16d60c5f4082da39f7c5cd38ea8a772b88e" dependencies: append-transform "^0.4.0" -istanbul-lib-instrument@^1.3.0: - version "1.4.2" - resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.4.2.tgz#0e2fdfac93c1dabf2e31578637dc78a19089f43e" +istanbul-lib-instrument@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.7.0.tgz#b8e0dc25709bb44e17336ab47b7bb5c97c23f659" dependencies: babel-generator "^6.18.0" babel-template "^6.16.0" babel-traverse "^6.18.0" babel-types "^6.18.0" babylon "^6.13.0" - istanbul-lib-coverage "^1.0.0" + istanbul-lib-coverage "^1.0.2" semver "^5.3.0" -istanbul-lib-report@^1.0.0-alpha.3: - version "1.0.0-alpha.3" - resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-1.0.0-alpha.3.tgz#32d5f6ec7f33ca3a602209e278b2e6ff143498af" +istanbul-lib-report@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-1.0.0.tgz#d83dac7f26566b521585569367fe84ccfc7aaecb" dependencies: - async "^1.4.2" - istanbul-lib-coverage "^1.0.0-alpha" + istanbul-lib-coverage "^1.0.2" mkdirp "^0.5.1" path-parse "^1.0.5" - rimraf "^2.4.3" supports-color "^3.1.2" -istanbul-lib-source-maps@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.1.0.tgz#9d429218f35b823560ea300a96ff0c3bbdab785f" +istanbul-lib-source-maps@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.1.1.tgz#f8c8c2e8f2160d1d91526d97e5bd63b2079af71c" dependencies: - istanbul-lib-coverage "^1.0.0-alpha.0" + istanbul-lib-coverage "^1.0.2" mkdirp "^0.5.1" rimraf "^2.4.4" source-map "^0.5.3" -istanbul-reports@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-1.0.1.tgz#9a17176bc4a6cbebdae52b2f15961d52fa623fbc" +istanbul-reports@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-1.0.2.tgz#4e8366abe6fa746cc1cd6633f108de12cc6ac6fa" dependencies: handlebars "^4.0.3" -jasmine-core@~2.5.2: - version "2.5.2" - resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.5.2.tgz#6f61bd79061e27f43e6f9355e44b3c6cab6ff297" - jasmine-reporters@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/jasmine-reporters/-/jasmine-reporters-2.2.0.tgz#e8c7916df3e4283bc8829a3fc21140eb322f8a5b" + version "2.2.1" + resolved "https://registry.yarnpkg.com/jasmine-reporters/-/jasmine-reporters-2.2.1.tgz#de9a9201367846269e7ca8adff5b44221671fcbd" dependencies: - jasmine "^2.4.1" mkdirp "^0.5.1" xmldom "^0.1.22" -jasmine@^2.4.1: - version "2.5.3" - resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-2.5.3.tgz#5441f254e1fc2269deb1dfd93e0e57d565ff4d22" - dependencies: - exit "^0.1.2" - glob "^7.0.6" - jasmine-core "~2.5.2" - jest-matcher-utils@^19.0.0: version "19.0.0" resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-19.0.0.tgz#5ecd9b63565d2b001f61fbf7ec4c7f537964564d" @@ -1708,9 +1698,10 @@ jsonpointer@^4.0.0: resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" jsprim@^1.2.2: - version "1.3.1" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.3.1.tgz#2a7256f70412a29ee3670aaca625994c4dcff252" + version "1.4.0" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.0.tgz#a3b87e40298d8c380552d8cc7628a0bb95a22918" dependencies: + assert-plus "1.0.0" extsprintf "1.0.2" json-schema "0.2.3" verror "1.3.6" @@ -1781,10 +1772,6 @@ load-json-file@^1.0.0: pinkie-promise "^2.0.0" strip-bom "^2.0.0" -lodash.pickby@^4.6.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.pickby/-/lodash.pickby-4.6.0.tgz#7dea21d8c18d7703a27c704c15d3b84a67e33aff" - lodash@^4.0.0, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -1858,15 +1845,15 @@ micromatch@^2.3.11: parse-glob "^3.0.4" regex-cache "^0.4.2" -mime-db@~1.26.0: - version "1.26.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.26.0.tgz#eaffcd0e4fc6935cf8134da246e2e6c35305adff" +mime-db@~1.27.0: + version "1.27.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1" mime-types@^2.1.12, mime-types@~2.1.7: - version "2.1.14" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.14.tgz#f7ef7d97583fcaf3b7d282b6f8b5679dab1e94ee" + version "2.1.15" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.15.tgz#a4ebf5064094569237b8cf70046776d09fc92aed" dependencies: - mime-db "~1.26.0" + mime-db "~1.27.0" mimic-fn@^1.0.0: version "1.1.0" @@ -1916,8 +1903,8 @@ node-fetch@^1.0.1: is-stream "^1.0.1" normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: - version "2.3.5" - resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.3.5.tgz#8d924f142960e1777e7ffe170543631cc7cb02df" + version "2.3.6" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.3.6.tgz#498fa420c96401f787402ba21e600def9f981fff" dependencies: hosted-git-info "^2.1.4" is-builtin-module "^1.0.0" @@ -1925,8 +1912,10 @@ normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: validate-npm-package-license "^3.0.1" normalize-path@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.0.1.tgz#47886ac1662760d4261b7d979d241709d3ce3f7a" + version "2.1.1" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" + dependencies: + remove-trailing-separator "^1.0.1" number-is-nan@^1.0.0: version "1.0.1" @@ -1980,8 +1969,8 @@ onetime@^1.0.0: resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" onetime@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.0.tgz#52aa8110e52fc5126ffc667bd8ec21c2ed209ce6" + version "2.0.1" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" dependencies: mimic-fn "^1.0.0" @@ -2149,9 +2138,9 @@ punycode@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" -qs@~6.3.0: - version "6.3.1" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.1.tgz#918c0b3bcd36679772baf135b1acb4c1651ed79d" +qs@~6.4.0: + version "6.4.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" randomatic@^1.1.3: version "1.1.6" @@ -2197,8 +2186,8 @@ read-pkg@^1.0.0: path-type "^1.0.0" readable-stream@^2.2.2: - version "2.2.3" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.3.tgz#9cf49463985df016c8ae8813097a9293a9b33729" + version "2.2.6" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.6.tgz#8b43aed76e71483938d12a8d46c6cf1a00b1f816" dependencies: buffer-shims "^1.0.0" core-util-is "~1.0.0" @@ -2275,6 +2264,10 @@ remark@^5.0.0: remark-stringify "^1.1.0" unified "^4.1.1" +remove-trailing-separator@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.0.1.tgz#615ebb96af559552d4bf4057c8436d486ab63cc4" + repeat-element@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" @@ -2290,8 +2283,8 @@ repeating@^2.0.0: is-finite "^1.0.0" request@>=2.42.0, request@^2.79.0: - version "2.80.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.80.0.tgz#8cc162d76d79381cdefdd3505d76b80b60589bd0" + version "2.81.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" dependencies: aws-sign2 "~0.6.0" aws4 "^1.2.1" @@ -2300,7 +2293,7 @@ request@>=2.42.0, request@^2.79.0: extend "~3.0.0" forever-agent "~0.6.1" form-data "~2.1.1" - har-validator "~4.2.0" + har-validator "~4.2.1" hawk "~3.1.3" http-signature "~1.1.0" is-typedarray "~1.0.0" @@ -2309,10 +2302,11 @@ request@>=2.42.0, request@^2.79.0: mime-types "~2.1.7" oauth-sign "~0.8.1" performance-now "^0.2.0" - qs "~6.3.0" + qs "~6.4.0" + safe-buffer "^5.0.1" stringstream "~0.0.4" tough-cookie "~2.3.0" - tunnel-agent "~0.4.1" + tunnel-agent "^0.6.0" uuid "^3.0.0" require-uncached@^1.0.2: @@ -2352,7 +2346,7 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" -rimraf@^2.2.8, rimraf@^2.4.3, rimraf@^2.4.4, rimraf@^2.5.4: +rimraf@^2.2.8, rimraf@^2.4.4, rimraf@^2.5.4: version "2.6.1" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" dependencies: @@ -2384,6 +2378,10 @@ rx@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782" +safe-buffer@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" + sax@^1.2.1: version "1.2.2" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.2.tgz#fd8631a23bc7826bef5d871bdb87378c95647828" @@ -2407,8 +2405,8 @@ shebang-regex@^1.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" shelljs@^0.7.5: - version "0.7.6" - resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.6.tgz#379cccfb56b91c8601e4793356eb5382924de9ad" + version "0.7.7" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.7.tgz#b2f5c77ef97148f4b4f6e22682e10bba8667cff1" dependencies: glob "^7.0.0" interpret "^1.0.0" @@ -2437,10 +2435,10 @@ sorted-object@^2.0.0: resolved "https://registry.yarnpkg.com/sorted-object/-/sorted-object-2.0.1.tgz#7d631f4bd3a798a24af1dffcfbfe83337a5df5fc" source-map-support@^0.4.2: - version "0.4.11" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.11.tgz#647f939978b38535909530885303daf23279f322" + version "0.4.14" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.14.tgz#9d4463772598b86271b4f523f6c1f4e02a7d6aef" dependencies: - source-map "^0.5.3" + source-map "^0.5.6" source-map@^0.4.4: version "0.4.4" @@ -2448,7 +2446,7 @@ source-map@^0.4.4: dependencies: amdefine ">=0.0.4" -source-map@^0.5.0, source-map@^0.5.3, source-map@~0.5.1: +source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1: version "0.5.6" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" @@ -2633,9 +2631,11 @@ tryit@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb" -tunnel-agent@~0.4.1: - version "0.4.3" - resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + dependencies: + safe-buffer "^5.0.1" tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" @@ -2652,21 +2652,21 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" typescript@^2.1.4: - version "2.2.1" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.2.1.tgz#4862b662b988a4c8ff691cc7969622d24db76ae9" + version "2.2.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.2.2.tgz#606022508479b55ffa368b58fee963a03dfd7b0c" ua-parser-js@^0.7.9: version "0.7.12" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb" uglify-js@^2.6: - version "2.8.5" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.5.tgz#ae9f5b143f4183d99a1dabb350e243fdc06641ed" + version "2.8.21" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.21.tgz#1733f669ae6f82fc90c7b25ec0f5c783ee375314" dependencies: - async "~0.2.6" source-map "~0.5.1" - uglify-to-browserify "~1.0.0" yargs "~3.10.0" + optionalDependencies: + uglify-to-browserify "~1.0.0" uglify-to-browserify@~1.0.0: version "1.0.2" @@ -2764,17 +2764,17 @@ whatwg-fetch@>=0.10.0: resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84" whatwg-url@^4.3.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-4.5.0.tgz#79bb6f0e370a4dda1cbc8f3062a490cf8bbb09ea" + version "4.7.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-4.7.0.tgz#202035ac1955b087cdd20fa8b58ded3ab1cd2af5" dependencies: tr46 "~0.0.3" webidl-conversions "^3.0.0" which@^1.2.9: - version "1.2.12" - resolved "https://registry.yarnpkg.com/which/-/which-1.2.12.tgz#de67b5e450269f194909ef23ece4ebe416fa1192" + version "1.2.14" + resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5" dependencies: - isexe "^1.1.1" + isexe "^2.0.0" window-size@0.1.0: version "0.1.0" @@ -2815,8 +2815,8 @@ xtend@^4.0.0, xtend@^4.0.1: resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" yallist@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.0.0.tgz#306c543835f09ee1a4cb23b7bce9ab341c91cdd4" + version "2.1.2" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" yargs@~3.10.0: version "3.10.0" From 8c486e7e55d525ee105c5de25c831ed30cae42c4 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 10 Apr 2017 08:19:49 +0500 Subject: [PATCH 53/59] remove usage of \t in reporter validation errors --- .../src/reporterValidationErrors.js | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/jest-config/src/reporterValidationErrors.js b/packages/jest-config/src/reporterValidationErrors.js index e59ea8838391..7f062d034455 100644 --- a/packages/jest-config/src/reporterValidationErrors.js +++ b/packages/jest-config/src/reporterValidationErrors.js @@ -26,10 +26,12 @@ function createReporterError( reporterIndex: number, reporterValue: any, ): ValidationError { - const errorMessage = `Reporter at index ${reporterIndex} must be of type:\n` + - `\t\t${chalk.bold.green(validReporterTypes.join(' or '))}\n` + - `\tbut instead received:\n` + - `\t\t${chalk.bold.red(getType(reporterValue))}`; + const errorMessage = ( + `Reporter at index ${reporterIndex} must be of type:\n` + + ` ${chalk.bold.green(validReporterTypes.join(' or '))}\n` + + ` but instead received:\n` + + ` ${chalk.bold.red(getType(reporterValue))}` + ); return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); } @@ -44,12 +46,14 @@ function createArrayReporterError( expectedType: string, valueName: string, ): ValidationError { - const errorMessage = `\tUnexpected value for ${valueName} at index ${valueIndex} of reporter` + + const errorMessage = ( + `Unexpected value for ${valueName} at index ${valueIndex} of reporter` + ` at index ${reporterIndex}\n` + - '\tExpected:\n' + - `\t\t${chalk.bold.red(expectedType)}\n` + - '\tGot:\n' + - `\t\t${chalk.bold.green(getType(value))}`; + ' Expected:\n' + + ` ${chalk.bold.red(expectedType)}\n` + + ' Got:\n' + + ` ${chalk.bold.green(getType(value))}` + ); return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); } From e328f93850819c6a387862c461822bfc938be493 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Mon, 10 Apr 2017 08:28:35 +0500 Subject: [PATCH 54/59] change spread operator with usage of .apply --- packages/jest-cli/src/ReporterDispatcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest-cli/src/ReporterDispatcher.js b/packages/jest-cli/src/ReporterDispatcher.js index 69d33f0fc034..330b3b8a65b6 100644 --- a/packages/jest-cli/src/ReporterDispatcher.js +++ b/packages/jest-cli/src/ReporterDispatcher.js @@ -90,7 +90,7 @@ class ReporterDispatcher { _callReporterMethod(method: string, reporterArgs: Array) { this._reporters.forEach(reporter => { if (reporter[method]) { - reporter[method](...reporterArgs); + reporter[method].apply(undefined, reporterArgs); } }); } From bfad068e62a0bb082ae15514272e6a17c9d7f4f9 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Tue, 11 Apr 2017 14:46:05 +0500 Subject: [PATCH 55/59] modify custom_reporters integration_tests to suit node 4 --- .../__snapshots__/custom-reporters-test.js.snap | 10 +++++----- integration_tests/__tests__/custom-reporters-test.js | 2 ++ .../custom_reporters/reporters/IncompleteReporter.js | 2 ++ .../custom_reporters/reporters/TestReporter.js | 10 ++++++---- packages/jest-cli/src/ReporterDispatcher.js | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap b/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap index 5b28e62f43da..7cd86bd25226 100644 --- a/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap +++ b/integration_tests/__tests__/__snapshots__/custom-reporters-test.js.snap @@ -73,11 +73,11 @@ Object { exports[`Custom Reporters Integration invalid format for adding reporters 1`] = ` "● Reporter Validation Error: - Unexpected value for Path at index 0 of reporter at index 0 - Expected: - string - Got: - number +Unexpected value for Path at index 0 of reporter at index 0 + Expected: + string + Got: + number Configuration Documentation: https://facebook.github.io/jest/docs/configuration.html diff --git a/integration_tests/__tests__/custom-reporters-test.js b/integration_tests/__tests__/custom-reporters-test.js index 4087f3f5cd53..1b913a2c8972 100644 --- a/integration_tests/__tests__/custom-reporters-test.js +++ b/integration_tests/__tests__/custom-reporters-test.js @@ -8,6 +8,8 @@ const runJest = require('../runJest'); const skipOnWindows = require('skipOnWindows'); +'use strict'; + describe('Custom Reporters Integration', () => { skipOnWindows.suite(); diff --git a/integration_tests/custom_reporters/reporters/IncompleteReporter.js b/integration_tests/custom_reporters/reporters/IncompleteReporter.js index 09c4e479004b..232a5b84c7a4 100644 --- a/integration_tests/custom_reporters/reporters/IncompleteReporter.js +++ b/integration_tests/custom_reporters/reporters/IncompleteReporter.js @@ -6,6 +6,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +'use strict'; + /** * IncompleteReporter * Reporter to test for the flexibility of the interface we implemented. diff --git a/integration_tests/custom_reporters/reporters/TestReporter.js b/integration_tests/custom_reporters/reporters/TestReporter.js index 36235614f35a..5a057c9194c1 100644 --- a/integration_tests/custom_reporters/reporters/TestReporter.js +++ b/integration_tests/custom_reporters/reporters/TestReporter.js @@ -6,6 +6,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +'use strict'; + /** * TestReporter * Reporter for testing the outputs, without any extra @@ -44,7 +46,7 @@ class TestReporter { } onTestStart(config, path) { - const {onTestStart} = this._statsCollected; + const onTestStart = this._statsCollected.onTestStart; onTestStart.called = true; onTestStart.config = config === undefined; @@ -52,7 +54,7 @@ class TestReporter { } onTestResult(config, testResult, results) { - const {onTestResult} = this._statsCollected; + const onTestResult = this._statsCollected.onTestResult; onTestResult.called = true; onTestResult.times++; @@ -60,7 +62,7 @@ class TestReporter { onRunStart(config, results, options) { this.clearLine(); - const {onRunStart} = this._statsCollected; + const onRunStart = this._statsCollected.onRunStart; onRunStart.called = true; onRunStart.config = typeof config; @@ -68,7 +70,7 @@ class TestReporter { } onRunComplete(config, results) { - const {onRunComplete} = this._statsCollected; + const onRunComplete = this._statsCollected.onRunComplete; onRunComplete.called = true; onRunComplete.config = typeof config; diff --git a/packages/jest-cli/src/ReporterDispatcher.js b/packages/jest-cli/src/ReporterDispatcher.js index 330b3b8a65b6..00bc95421cee 100644 --- a/packages/jest-cli/src/ReporterDispatcher.js +++ b/packages/jest-cli/src/ReporterDispatcher.js @@ -90,7 +90,7 @@ class ReporterDispatcher { _callReporterMethod(method: string, reporterArgs: Array) { this._reporters.forEach(reporter => { if (reporter[method]) { - reporter[method].apply(undefined, reporterArgs); + reporter[method].apply(reporter, reporterArgs); } }); } From f4ed43604c6a26821c491bbcb19ceb89b0727ab3 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Tue, 11 Apr 2017 15:04:37 +0500 Subject: [PATCH 56/59] prettier validations --- packages/jest-config/src/reporterValidationErrors.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/jest-config/src/reporterValidationErrors.js b/packages/jest-config/src/reporterValidationErrors.js index 7f062d034455..6472b8c7a34f 100644 --- a/packages/jest-config/src/reporterValidationErrors.js +++ b/packages/jest-config/src/reporterValidationErrors.js @@ -26,12 +26,10 @@ function createReporterError( reporterIndex: number, reporterValue: any, ): ValidationError { - const errorMessage = ( - `Reporter at index ${reporterIndex} must be of type:\n` + + const errorMessage = `Reporter at index ${reporterIndex} must be of type:\n` + ` ${chalk.bold.green(validReporterTypes.join(' or '))}\n` + ` but instead received:\n` + - ` ${chalk.bold.red(getType(reporterValue))}` - ); + ` ${chalk.bold.red(getType(reporterValue))}`; return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); } @@ -46,14 +44,12 @@ function createArrayReporterError( expectedType: string, valueName: string, ): ValidationError { - const errorMessage = ( - `Unexpected value for ${valueName} at index ${valueIndex} of reporter` + + const errorMessage = `Unexpected value for ${valueName} at index ${valueIndex} of reporter` + ` at index ${reporterIndex}\n` + ' Expected:\n' + ` ${chalk.bold.red(expectedType)}\n` + ' Got:\n' + - ` ${chalk.bold.green(getType(value))}` - ); + ` ${chalk.bold.green(getType(value))}`; return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); } From f6fa7bb6df3f04193b06ca6ba5420395ee024b96 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Tue, 11 Apr 2017 16:27:52 +0500 Subject: [PATCH 57/59] prettier :heart: --- integration_tests/__tests__/custom-reporters-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_tests/__tests__/custom-reporters-test.js b/integration_tests/__tests__/custom-reporters-test.js index 1b913a2c8972..183a8b81734f 100644 --- a/integration_tests/__tests__/custom-reporters-test.js +++ b/integration_tests/__tests__/custom-reporters-test.js @@ -5,11 +5,11 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ +'use strict'; + const runJest = require('../runJest'); const skipOnWindows = require('skipOnWindows'); -'use strict'; - describe('Custom Reporters Integration', () => { skipOnWindows.suite(); From 9ac6de055c139db116ff87d2ef113a0126c0ec07 Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Tue, 11 Apr 2017 16:53:53 +0500 Subject: [PATCH 58/59] pretty lint --- packages/jest-config/src/reporterValidationErrors.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jest-config/src/reporterValidationErrors.js b/packages/jest-config/src/reporterValidationErrors.js index 6472b8c7a34f..173e7249ca61 100644 --- a/packages/jest-config/src/reporterValidationErrors.js +++ b/packages/jest-config/src/reporterValidationErrors.js @@ -44,8 +44,8 @@ function createArrayReporterError( expectedType: string, valueName: string, ): ValidationError { - const errorMessage = `Unexpected value for ${valueName} at index ${valueIndex} of reporter` + - ` at index ${reporterIndex}\n` + + const errorMessage = `Unexpected value for ${valueName} ` + + `at index ${valueIndex} of reporter at index ${reporterIndex}\n` + ' Expected:\n' + ` ${chalk.bold.red(expectedType)}\n` + ' Got:\n' + From e0931251ece7bef775792345a8ed9744e734fc2b Mon Sep 17 00:00:00 2001 From: Hannan Ali Date: Tue, 11 Apr 2017 16:54:15 +0500 Subject: [PATCH 59/59] update lock file --- yarn.lock | 213 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 111 insertions(+), 102 deletions(-) diff --git a/yarn.lock b/yarn.lock index ab4618b1727e..60a5a925fc96 100644 --- a/yarn.lock +++ b/yarn.lock @@ -35,8 +35,8 @@ ajv-keywords@^1.0.0: resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" ajv@^4.7.0, ajv@^4.9.1: - version "4.11.5" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.5.tgz#b6ee74657b993a01dce44b7944d56f485828d5bd" + version "4.11.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.6.tgz#947e93049790942b2a2d60a8289b28924d39f987" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" @@ -184,19 +184,19 @@ babel-code-frame@6.22.0, babel-code-frame@^6.16.0, babel-code-frame@^6.22.0: esutils "^2.0.2" js-tokens "^3.0.0" -babel-core@^6.23.1, babel-core@^6.24.0: - version "6.24.0" - resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.24.0.tgz#8f36a0a77f5c155aed6f920b844d23ba56742a02" +babel-core@^6.23.1, babel-core@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.24.1.tgz#8c428564dce1e1f41fb337ec34f4c3b022b5ad83" dependencies: babel-code-frame "^6.22.0" - babel-generator "^6.24.0" - babel-helpers "^6.23.0" + babel-generator "^6.24.1" + babel-helpers "^6.24.1" babel-messages "^6.23.0" - babel-register "^6.24.0" + babel-register "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.1" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" babylon "^6.11.0" convert-source-map "^1.1.0" debug "^2.1.1" @@ -217,68 +217,68 @@ babel-eslint@^7.1.1: babel-types "^6.23.0" babylon "^6.16.1" -babel-generator@^6.18.0, babel-generator@^6.24.0: - version "6.24.0" - resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.24.0.tgz#eba270a8cc4ce6e09a61be43465d7c62c1f87c56" +babel-generator@^6.18.0, babel-generator@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.24.1.tgz#e715f486c58ded25649d888944d52aa07c5d9497" dependencies: babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-types "^6.23.0" + babel-types "^6.24.1" detect-indent "^4.0.0" jsesc "^1.3.0" lodash "^4.2.0" source-map "^0.5.0" trim-right "^1.0.1" -babel-helper-call-delegate@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-helper-call-delegate/-/babel-helper-call-delegate-6.22.0.tgz#119921b56120f17e9dae3f74b4f5cc7bcc1b37ef" +babel-helper-call-delegate@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz#ece6aacddc76e41c3461f88bfc575bd0daa2df8d" dependencies: - babel-helper-hoist-variables "^6.22.0" + babel-helper-hoist-variables "^6.24.1" babel-runtime "^6.22.0" - babel-traverse "^6.22.0" - babel-types "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-helper-function-name@^6.22.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.23.0.tgz#25742d67175c8903dbe4b6cb9d9e1fcb8dcf23a6" +babel-helper-function-name@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" dependencies: - babel-helper-get-function-arity "^6.22.0" + babel-helper-get-function-arity "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-helper-get-function-arity@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.22.0.tgz#0beb464ad69dc7347410ac6ade9f03a50634f5ce" +babel-helper-get-function-arity@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d" dependencies: babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" -babel-helper-hoist-variables@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.22.0.tgz#3eacbf731d80705845dd2e9718f600cfb9b4ba72" +babel-helper-hoist-variables@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz#1ecb27689c9d25513eadbc9914a73f5408be7a76" dependencies: babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" -babel-helper-remap-async-to-generator@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.22.0.tgz#2186ae73278ed03b8b15ced089609da981053383" +babel-helper-remap-async-to-generator@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b" dependencies: - babel-helper-function-name "^6.22.0" + babel-helper-function-name "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.22.0" - babel-traverse "^6.22.0" - babel-types "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-helpers@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.23.0.tgz#4f8f2e092d0b6a8808a4bde79c27f1e2ecf0d992" +babel-helpers@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" dependencies: babel-runtime "^6.22.0" - babel-template "^6.23.0" + babel-template "^6.24.1" babel-messages@^6.23.0: version "6.23.0" @@ -299,10 +299,10 @@ babel-plugin-syntax-trailing-function-commas@^6.13.0: resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" babel-plugin-transform-async-to-generator@^6.16.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.22.0.tgz#194b6938ec195ad36efc4c33a971acf00d8cd35e" + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761" dependencies: - babel-helper-remap-async-to-generator "^6.22.0" + babel-helper-remap-async-to-generator "^6.24.1" babel-plugin-syntax-async-functions "^6.8.0" babel-runtime "^6.22.0" @@ -313,15 +313,15 @@ babel-plugin-transform-es2015-destructuring@^6.23.0: babel-runtime "^6.22.0" babel-plugin-transform-es2015-parameters@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.23.0.tgz#3a2aabb70c8af945d5ce386f1a4250625a83ae3b" + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" dependencies: - babel-helper-call-delegate "^6.22.0" - babel-helper-get-function-arity "^6.22.0" + babel-helper-call-delegate "^6.24.1" + babel-helper-get-function-arity "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" babel-plugin-transform-flow-strip-types@^6.18.0: version "6.22.0" @@ -330,11 +330,11 @@ babel-plugin-transform-flow-strip-types@^6.18.0: babel-plugin-syntax-flow "^6.18.0" babel-runtime "^6.22.0" -babel-register@^6.24.0: - version "6.24.0" - resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.24.0.tgz#5e89f8463ba9970356d02eb07dabe3308b080cfd" +babel-register@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.24.1.tgz#7e10e13a2f71065bdfad5a1787ba45bca6ded75f" dependencies: - babel-core "^6.24.0" + babel-core "^6.24.1" babel-runtime "^6.22.0" core-js "^2.4.0" home-or-tmp "^2.0.0" @@ -349,33 +349,33 @@ babel-runtime@^6.22.0: core-js "^2.4.0" regenerator-runtime "^0.10.0" -babel-template@^6.16.0, babel-template@^6.22.0, babel-template@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.23.0.tgz#04d4f270adbb3aa704a8143ae26faa529238e638" +babel-template@^6.16.0, babel-template@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.24.1.tgz#04ae514f1f93b3a2537f2a0f60a5a45fb8308333" dependencies: babel-runtime "^6.22.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" babylon "^6.11.0" lodash "^4.2.0" -babel-traverse@^6.18.0, babel-traverse@^6.22.0, babel-traverse@^6.23.0, babel-traverse@^6.23.1: - version "6.23.1" - resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.23.1.tgz#d3cb59010ecd06a97d81310065f966b699e14f48" +babel-traverse@^6.18.0, babel-traverse@^6.23.1, babel-traverse@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.24.1.tgz#ab36673fd356f9a0948659e7b338d5feadb31695" dependencies: babel-code-frame "^6.22.0" babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-types "^6.23.0" + babel-types "^6.24.1" babylon "^6.15.0" debug "^2.2.0" globals "^9.0.0" invariant "^2.2.0" lodash "^4.2.0" -babel-types@^6.18.0, babel-types@^6.22.0, babel-types@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.23.0.tgz#bb17179d7538bad38cd0c9e115d340f77e7e9acf" +babel-types@^6.18.0, babel-types@^6.23.0, babel-types@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.24.1.tgz#a136879dc15b3606bda0d90c1fc74304c2ff0975" dependencies: babel-runtime "^6.22.0" esutils "^2.0.2" @@ -411,8 +411,8 @@ boom@2.x.x: hoek "2.x.x" brace-expansion@^1.0.0: - version "1.1.6" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9" + version "1.1.7" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59" dependencies: balanced-match "^0.4.1" concat-map "0.0.1" @@ -425,7 +425,7 @@ braces@^1.8.2: preserve "^0.2.0" repeat-element "^1.1.2" -buffer-shims@^1.0.0: +buffer-shims@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" @@ -1016,7 +1016,7 @@ fast-levenshtein@~2.0.4: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" -fbjs@^0.8.4: +fbjs@^0.8.9: version "0.8.12" resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.12.tgz#10b5d92f76d45575fd63a217d4ea02bea2f8ed04" dependencies: @@ -1086,8 +1086,8 @@ flat-cache@^1.2.1: write "^0.2.1" flow-bin@^0.43.0: - version "0.43.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.43.0.tgz#5cd16696be4311c0b14f0932e89ba8661a39b1c1" + version "0.43.1" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.43.1.tgz#0733958b448fb8ad4b1576add7e87c31794c81bc" flow-parser@0.40.0: version "0.40.0" @@ -1116,8 +1116,8 @@ forever-agent@~0.6.1: resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" form-data@~2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.2.tgz#89c3534008b97eada4cbb157d58f6f5df025eae4" + version "2.1.4" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" dependencies: asynckit "^0.4.0" combined-stream "^1.0.5" @@ -1282,8 +1282,8 @@ iconv-lite@0.4.13, iconv-lite@~0.4.13: resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2" ignore@^3.2.0: - version "3.2.6" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.2.6.tgz#26e8da0644be0bb4cb39516f6c79f0e0f4ffe48c" + version "3.2.7" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.2.7.tgz#4810ca5f1d8eca5595213a34b94f2eb4ed926bbd" immutable@^4.0.0-rc.1: version "4.0.0-rc.2" @@ -1633,8 +1633,8 @@ js-tokens@^3.0.0: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" js-yaml@^3.5.1, js-yaml@^3.7.0: - version "3.8.2" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.2.tgz#02d3e2c0f6beab20248d412c352203827d786721" + version "3.8.3" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.3.tgz#33a05ec481c850c8875929166fe1beb61c728766" dependencies: argparse "^1.0.7" esprima "^3.1.1" @@ -2130,6 +2130,12 @@ promise@^7.1.1: dependencies: asap "~2.0.3" +prop-types@^15.5.2: + version "15.5.6" + resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.6.tgz#797a915b1714b645ebb7c5d6cc690346205bd2aa" + dependencies: + fbjs "^0.8.9" + pseudomap@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" @@ -2150,19 +2156,20 @@ randomatic@^1.1.3: kind-of "^3.0.2" react-test-renderer@^15.4.1: - version "15.4.2" - resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-15.4.2.tgz#27e1dff5d26d0e830f99614c487622bc831416f3" + version "15.5.4" + resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-15.5.4.tgz#d4ebb23f613d685ea8f5390109c2d20fbf7c83bc" dependencies: - fbjs "^0.8.4" + fbjs "^0.8.9" object-assign "^4.1.0" react@^15.4.1: - version "15.4.2" - resolved "https://registry.yarnpkg.com/react/-/react-15.4.2.tgz#41f7991b26185392ba9bae96c8889e7e018397ef" + version "15.5.3" + resolved "https://registry.yarnpkg.com/react/-/react-15.5.3.tgz#84055382c025dec4e3b902bb61a8697cc79c1258" dependencies: - fbjs "^0.8.4" + fbjs "^0.8.9" loose-envify "^1.1.0" object-assign "^4.1.0" + prop-types "^15.5.2" read-cmd-shim@^1.0.1: version "1.0.1" @@ -2186,15 +2193,15 @@ read-pkg@^1.0.0: path-type "^1.0.0" readable-stream@^2.2.2: - version "2.2.6" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.6.tgz#8b43aed76e71483938d12a8d46c6cf1a00b1f816" + version "2.2.9" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.9.tgz#cf78ec6f4a6d1eb43d26488cac97f042e74b7fc8" dependencies: - buffer-shims "^1.0.0" + buffer-shims "~1.0.0" core-util-is "~1.0.0" inherits "~2.0.1" isarray "~1.0.0" process-nextick-args "~1.0.6" - string_decoder "~0.10.x" + string_decoder "~1.0.0" util-deprecate "~1.0.1" readline2@^1.0.1: @@ -2504,9 +2511,11 @@ string-width@^2.0.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^3.0.0" -string_decoder@~0.10.x: - version "0.10.31" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" +string_decoder@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.0.tgz#f06f41157b664d86069f84bdbdc9b0d8ab281667" + dependencies: + buffer-shims "~1.0.0" stringify-entities@^1.0.1: version "1.3.0" @@ -2652,16 +2661,16 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" typescript@^2.1.4: - version "2.2.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.2.2.tgz#606022508479b55ffa368b58fee963a03dfd7b0c" + version "2.3.0" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.3.0.tgz#2e63e09284392bc8158a2444c33e2093795c0418" ua-parser-js@^0.7.9: version "0.7.12" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb" uglify-js@^2.6: - version "2.8.21" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.21.tgz#1733f669ae6f82fc90c7b25ec0f5c783ee375314" + version "2.8.22" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.22.tgz#d54934778a8da14903fa29a326fb24c0ab51a1a0" dependencies: source-map "~0.5.1" yargs "~3.10.0"