diff --git a/e2e/__tests__/test_retries.test.js b/e2e/__tests__/test_retries.test.js index fa7f1159aceb..9c2a7347212c 100644 --- a/e2e/__tests__/test_retries.test.js +++ b/e2e/__tests__/test_retries.test.js @@ -40,7 +40,7 @@ describe('Test Retries', () => { const reporterConfig = { reporters: [ - ['/reporters/RetryReporter.js', { output: outputFilePath }], + ['/reporters/RetryReporter.js', {output: outputFilePath}], ], }; @@ -71,7 +71,7 @@ describe('Test Retries', () => { const reporterConfig = { reporters: [ - ['/reporters/RetryReporter.js', { output: outputFilePath }], + ['/reporters/RetryReporter.js', {output: outputFilePath}], ], }; diff --git a/packages/jest-circus/src/run.js b/packages/jest-circus/src/run.js index c3da55f0ada2..6599911835ea 100644 --- a/packages/jest-circus/src/run.js +++ b/packages/jest-circus/src/run.js @@ -9,13 +9,13 @@ import type { RunResult, - TestEntry, - TestContext, - Hook, - DescribeBlock, + TestEntry, + TestContext, + Hook, + DescribeBlock, } from 'types/Circus'; -import { getState, dispatch } from './state'; +import {getState, dispatch} from './state'; import { callAsyncFn, getAllHooksForDescribe, @@ -29,10 +29,10 @@ import { const Promise = getOriginalPromise(); const run = async (): Promise => { - const { rootDescribeBlock } = getState(); - dispatch({ name: 'run_start' }); + const {rootDescribeBlock} = getState(); + dispatch({name: 'run_start'}); await _runTestsForDescribeBlock(rootDescribeBlock); - dispatch({ name: 'run_finish' }); + dispatch({name: 'run_finish'}); return makeRunResult( getState().rootDescribeBlock, getState().unhandledErrors, @@ -40,11 +40,11 @@ const run = async (): Promise => { }; const _runTestsForDescribeBlock = async (describeBlock: DescribeBlock) => { - dispatch({ describeBlock, name: 'run_describe_start' }); - const { beforeAll, afterAll } = getAllHooksForDescribe(describeBlock); + dispatch({describeBlock, name: 'run_describe_start'}); + const {beforeAll, afterAll} = getAllHooksForDescribe(describeBlock); for (const hook of beforeAll) { - await _callHook({ describeBlock, hook }); + await _callHook({describeBlock, hook}); } // Tests that fail and are retried we run after other tests @@ -78,15 +78,15 @@ const _runTestsForDescribeBlock = async (describeBlock: DescribeBlock) => { } for (const hook of afterAll) { - await _callHook({ describeBlock, hook }); + await _callHook({describeBlock, hook}); } - dispatch({ describeBlock, name: 'run_describe_finish' }); + dispatch({describeBlock, name: 'run_describe_finish'}); }; const _runTest = async (test: TestEntry): Promise => { - dispatch({ name: 'test_start', test }); + dispatch({name: 'test_start', test}); const testContext = Object.create(null); - const { hasFocusedTests, testNamePattern } = getState(); + const {hasFocusedTests, testNamePattern} = getState(); const isSkipped = test.mode === 'skip' || @@ -94,11 +94,11 @@ const _runTest = async (test: TestEntry): Promise => { (testNamePattern && !testNamePattern.test(getTestID(test))); if (isSkipped) { - dispatch({ name: 'test_skip', test }); + dispatch({name: 'test_skip', test}); return; } - const { afterEach, beforeEach } = getEachHooksForTest(test); + const {afterEach, beforeEach} = getEachHooksForTest(test); for (const hook of beforeEach) { if (test.errors.length) { @@ -106,19 +106,19 @@ const _runTest = async (test: TestEntry): Promise => { // hooks after that. break; } - await _callHook({ hook, test, testContext }); + await _callHook({hook, test, testContext}); } await _callTest(test, testContext); for (const hook of afterEach) { - await _callHook({ hook, test, testContext }); + await _callHook({hook, test, testContext}); } // `afterAll` hooks should not affect test status (pass or fail), because if // we had a global `afterAll` hook it would block all existing tests until // this hook is executed. So we dispatche `test_done` right away. - dispatch({ name: 'test_done', test }); + dispatch({name: 'test_done', test}); }; const _callHook = ({ @@ -127,25 +127,25 @@ const _callHook = ({ describeBlock, testContext, }: { - hook: Hook, - describeBlock?: DescribeBlock, - test?: TestEntry, - testContext?: TestContext, - }): Promise => { - dispatch({ hook, name: 'hook_start' }); + hook: Hook, + describeBlock?: DescribeBlock, + test?: TestEntry, + testContext?: TestContext, +}): Promise => { + dispatch({hook, name: 'hook_start'}); const timeout = hook.timeout || getState().testTimeout; - return callAsyncFn(hook.fn, testContext, { isHook: true, timeout }) - .then(() => dispatch({ describeBlock, hook, name: 'hook_success', test })) + return callAsyncFn(hook.fn, testContext, {isHook: true, timeout}) + .then(() => dispatch({describeBlock, hook, name: 'hook_success', test})) .catch(error => - dispatch({ describeBlock, error, hook, name: 'hook_failure', test }), - ); + dispatch({describeBlock, error, hook, name: 'hook_failure', test}), + ); }; const _callTest = async ( test: TestEntry, testContext: TestContext, ): Promise => { - dispatch({ name: 'test_fn_start', test }); + dispatch({name: 'test_fn_start', test}); const timeout = test.timeout || getState().testTimeout; invariant(test.fn, `Tests with no 'fn' should have 'mode' set to 'skipped'`); @@ -154,9 +154,9 @@ const _callTest = async ( return; } - await callAsyncFn(test.fn, testContext, { isHook: false, timeout }) - .then(() => dispatch({ name: 'test_fn_success', test })) - .catch(error => dispatch({ error, name: 'test_fn_failure', test })); + await callAsyncFn(test.fn, testContext, {isHook: false, timeout}) + .then(() => dispatch({name: 'test_fn_success', test})) + .catch(error => dispatch({error, name: 'test_fn_failure', test})); }; export default run;