From 6f322330100d501cb8cde6cb1abdb92b3b5180d6 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sat, 26 May 2018 16:08:30 +0100 Subject: [PATCH 1/4] Run with Jest Circus when passing the JEST_CIRCUS env variable as 1 This will: 1. Make it easy to run a test locally with Jest Circus 2. Enable us to flag individual tests as known to be failing on Jest Circus. 3. Make it easy to run Jest Circus on other code bases. 4. Once 2 is complete, we can setup a second CI run that uses Jest Circus to ensure we don't regress. --- integration-tests/__tests__/each.test.js | 2 ++ packages/jest-runner/src/run_test.js | 6 ++++- scripts/SkipOnJestCircus.js | 30 ++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 scripts/SkipOnJestCircus.js diff --git a/integration-tests/__tests__/each.test.js b/integration-tests/__tests__/each.test.js index 54e16cfda251..6e49091519be 100644 --- a/integration-tests/__tests__/each.test.js +++ b/integration-tests/__tests__/each.test.js @@ -14,8 +14,10 @@ const runJest = require('../runJest'); const {extractSummary} = require('../Utils'); const dir = path.resolve(__dirname, '../each'); const SkipOnWindows = require('../../scripts/SkipOnWindows'); +const SkipOnJestCircus = require('../../scripts/SkipOnJestCircus'); SkipOnWindows.suite(); +SkipOnJestCircus.suite(); test('works with passing tests', () => { const result = runJest(dir, ['success.test.js']); diff --git a/packages/jest-runner/src/run_test.js b/packages/jest-runner/src/run_test.js index 8a351610c856..a72116278029 100644 --- a/packages/jest-runner/src/run_test.js +++ b/packages/jest-runner/src/run_test.js @@ -69,7 +69,11 @@ async function runTestInternal( /* $FlowFixMe */ const TestEnvironment = (require(testEnvironment): EnvironmentClass); /* $FlowFixMe */ - const testFramework = (require(config.testRunner): TestFramework); + const testFramework = ((process.env.JEST_CIRCUS === '1' + ? // eslint-disable-next-line import/no-extraneous-dependencies + require('jest-circus/build/legacy_code_todo_rewrite/jest_adapter.js') + .default + : require(config.testRunner)): TestFramework); /* $FlowFixMe */ const Runtime = (require(config.moduleLoader || 'jest-runtime'): Class< RuntimeClass, diff --git a/scripts/SkipOnJestCircus.js b/scripts/SkipOnJestCircus.js new file mode 100644 index 000000000000..ac704ca79780 --- /dev/null +++ b/scripts/SkipOnJestCircus.js @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + */ + +/* eslint-disable jest/no-focused-tests */ + +const SkipOnWindows = { + suite() { + if (process.env.JEST_CIRCUS === '1') { + fit('does not work on jest-circus', () => { + console.warn('[SKIP] Does not work on jest-circus'); + }); + } + }, + + test() { + if (process.env.JEST_CIRCUS === '1') { + console.warn('[SKIP] Does not work on jest-circus'); + return true; + } + return false; + }, +}; + +module.exports = SkipOnWindows; From f4cd3cc16d057a2ab1460089711e84335d8211ed Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sat, 26 May 2018 16:25:05 +0100 Subject: [PATCH 2/4] Fix copy/paste name error --- scripts/SkipOnJestCircus.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/SkipOnJestCircus.js b/scripts/SkipOnJestCircus.js index ac704ca79780..b4460d38dfb9 100644 --- a/scripts/SkipOnJestCircus.js +++ b/scripts/SkipOnJestCircus.js @@ -9,7 +9,7 @@ /* eslint-disable jest/no-focused-tests */ -const SkipOnWindows = { +const SkipOnJestCircus = { suite() { if (process.env.JEST_CIRCUS === '1') { fit('does not work on jest-circus', () => { @@ -27,4 +27,4 @@ const SkipOnWindows = { }, }; -module.exports = SkipOnWindows; +module.exports = SkipOnJestCircus; From 502ae146aeccc30fe2dcddf3efd9844551817d83 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sat, 26 May 2018 16:34:20 +0100 Subject: [PATCH 3/4] Fix lint/flow --- packages/jest-runner/src/run_test.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/jest-runner/src/run_test.js b/packages/jest-runner/src/run_test.js index a72116278029..886d2ffa29b6 100644 --- a/packages/jest-runner/src/run_test.js +++ b/packages/jest-runner/src/run_test.js @@ -66,12 +66,10 @@ async function runTestInternal( ); } - /* $FlowFixMe */ const TestEnvironment = (require(testEnvironment): EnvironmentClass); - /* $FlowFixMe */ const testFramework = ((process.env.JEST_CIRCUS === '1' - ? // eslint-disable-next-line import/no-extraneous-dependencies - require('jest-circus/build/legacy_code_todo_rewrite/jest_adapter.js') + ? /* $FlowFixMe */ + require('jest-circus/build/legacy_code_todo_rewrite/jest_adapter.js') // eslint-disable-line import/no-extraneous-dependencies .default : require(config.testRunner)): TestFramework); /* $FlowFixMe */ From a31a80966a6b971871e3f9a8ce1966c622a3ee1b Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sat, 26 May 2018 16:37:20 +0100 Subject: [PATCH 4/4] Fix flow/lint again --- packages/jest-runner/src/run_test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/jest-runner/src/run_test.js b/packages/jest-runner/src/run_test.js index 886d2ffa29b6..e190f2e9e437 100644 --- a/packages/jest-runner/src/run_test.js +++ b/packages/jest-runner/src/run_test.js @@ -66,12 +66,14 @@ async function runTestInternal( ); } + /* $FlowFixMe */ const TestEnvironment = (require(testEnvironment): EnvironmentClass); const testFramework = ((process.env.JEST_CIRCUS === '1' ? /* $FlowFixMe */ require('jest-circus/build/legacy_code_todo_rewrite/jest_adapter.js') // eslint-disable-line import/no-extraneous-dependencies .default - : require(config.testRunner)): TestFramework); + : /* $FlowFixMe */ + require(config.testRunner)): TestFramework); /* $FlowFixMe */ const Runtime = (require(config.moduleLoader || 'jest-runtime'): Class< RuntimeClass,