From 948166bb2d18b46df95a3214167eacbad5376802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olle=20Lauri=20Bostr=C3=B6m?= Date: Wed, 27 Feb 2019 10:06:56 +0100 Subject: [PATCH] feat(jest-runner): disable notifications (#1419) Turning off jest notifications when running with Stryker: https://media.giphy.com/media/8UGFvYxcwWWDrblA77/giphy.gif --- packages/jest-runner/src/jestOverrideOptions.ts | 4 ++++ .../jest-runner/test/integration/JestConfigEditor.it.spec.ts | 5 +++++ packages/jest-runner/test/unit/JestConfigEditor.spec.ts | 3 ++- .../jest-runner/testResources/exampleProject/package.json | 3 ++- .../exampleProjectWithExplicitJestConfig/jest.config.js | 5 +++-- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/jest-runner/src/jestOverrideOptions.ts b/packages/jest-runner/src/jestOverrideOptions.ts index 71b5cb688a..1da36168de 100644 --- a/packages/jest-runner/src/jestOverrideOptions.ts +++ b/packages/jest-runner/src/jestOverrideOptions.ts @@ -11,6 +11,10 @@ const JEST_OVERRIDE_OPTIONS = Object.freeze({ // Disable bail so the jest process does not quit with a non-zero exit code bail: false, + + // Disable notifications for test results, this will otherwise show a notification about + // the results each time Stryker runs the tests + notify: false }); export default JEST_OVERRIDE_OPTIONS; diff --git a/packages/jest-runner/test/integration/JestConfigEditor.it.spec.ts b/packages/jest-runner/test/integration/JestConfigEditor.it.spec.ts index 47b884368b..fea39a4336 100644 --- a/packages/jest-runner/test/integration/JestConfigEditor.it.spec.ts +++ b/packages/jest-runner/test/integration/JestConfigEditor.it.spec.ts @@ -49,6 +49,7 @@ describe('Integration test for Jest ConfigEditor', () => { '^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy', '^react-native$': 'react-native-web' }, + notify: false, rootDir: projectRoot, setupFiles: [path.join(projectRoot, 'node_modules', 'react-app-polyfill', 'jsdom.js')], setupTestFrameworkScriptFile: undefined, @@ -107,6 +108,7 @@ describe('Integration test for Jest ConfigEditor', () => { moduleNameMapper: { '^react-native$': 'react-native-web' }, + notify: false, rootDir: projectRoot, setupFiles: [path.join(projectRoot, 'node_modules', 'react-scripts-ts', 'config', 'polyfills.js')], setupTestFrameworkScriptFile: undefined, @@ -142,6 +144,7 @@ describe('Integration test for Jest ConfigEditor', () => { bail: false, collectCoverage: false, moduleFileExtensions: ['js', 'json', 'jsx', 'node'], + notify: false, testEnvironment: 'jest-environment-jsdom', testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$', testResultsProcessor: undefined, @@ -161,6 +164,7 @@ describe('Integration test for Jest ConfigEditor', () => { bail: false, collectCoverage: false, moduleFileExtensions: ['js', 'json', 'jsx', 'node'], + notify: false, testEnvironment: 'jest-environment-jsdom', testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$', testResultsProcessor: undefined, @@ -178,6 +182,7 @@ describe('Integration test for Jest ConfigEditor', () => { expect(config.jest.config).to.deep.equal({ bail: false, collectCoverage: false, + notify: false, testResultsProcessor: undefined, verbose: false, }); diff --git a/packages/jest-runner/test/unit/JestConfigEditor.spec.ts b/packages/jest-runner/test/unit/JestConfigEditor.spec.ts index c746118d9f..d2e70fe5de 100644 --- a/packages/jest-runner/test/unit/JestConfigEditor.spec.ts +++ b/packages/jest-runner/test/unit/JestConfigEditor.spec.ts @@ -56,12 +56,13 @@ describe('JestConfigEditor', () => { assert(reactScriptsTSJestConfigLoaderStub.loadConfig.calledOnce, 'ReactScriptsTSJestConfigLoader loadConfig not called'); }); - it('should override verbose, collectCoverage, testResultsProcessor and bail on all loaded configs', () => { + it('should override verbose, collectCoverage, testResultsProcessor, notify and bail on all loaded configs', () => { sut.edit(config); expect(config.jest.config).to.deep.equal({ bail: false, collectCoverage: false, + notify: false, testResultsProcessor: undefined, verbose: false }); diff --git a/packages/jest-runner/testResources/exampleProject/package.json b/packages/jest-runner/testResources/exampleProject/package.json index dfa1888bf6..075fe35282 100644 --- a/packages/jest-runner/testResources/exampleProject/package.json +++ b/packages/jest-runner/testResources/exampleProject/package.json @@ -12,6 +12,7 @@ "testURL": "http://localhost", "collectCoverage": true, "verbose": true, - "bail": false + "bail": false, + "notify": true } } diff --git a/packages/jest-runner/testResources/exampleProjectWithExplicitJestConfig/jest.config.js b/packages/jest-runner/testResources/exampleProjectWithExplicitJestConfig/jest.config.js index 24fefa7b20..3b2cfef3d1 100644 --- a/packages/jest-runner/testResources/exampleProjectWithExplicitJestConfig/jest.config.js +++ b/packages/jest-runner/testResources/exampleProjectWithExplicitJestConfig/jest.config.js @@ -7,5 +7,6 @@ module.exports = { collectCoverage: true, verbose: true, testURL: "http://localhost", - bail: false -} \ No newline at end of file + bail: false, + notify: true, +}