From e903535a7a13114cbf01749d04b72e794ad69ae5 Mon Sep 17 00:00:00 2001 From: MrLoh Date: Fri, 1 May 2020 16:49:50 -0500 Subject: [PATCH] build basic async skip functionality --- packages/jest-circus/src/run.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/jest-circus/src/run.ts b/packages/jest-circus/src/run.ts index eabd09411a44..007ee89f7c04 100644 --- a/packages/jest-circus/src/run.ts +++ b/packages/jest-circus/src/run.ts @@ -82,7 +82,14 @@ const _runTestsForDescribeBlock = async ( const _runTest = async (test: Circus.TestEntry): Promise => { await dispatch({name: 'test_start', test}); - const testContext = Object.create(null); + + const testContext: Circus.TestContext = {}; + testContext.asyncSkipped = false; + testContext.skip = async () => { + testContext.canceled = true; + await dispatch({name: 'test_skip', test}); + }; + const {hasFocusedTests, testNamePattern} = getState(); const isSkipped = @@ -120,7 +127,9 @@ const _runTest = async (test: Circus.TestEntry): Promise => { // `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 dispatch `test_done` right away. - await dispatch({name: 'test_done', test}); + if (!testContext.asyncSkipped) { + await dispatch({name: 'test_done', test}); + } }; const _callCircusHook = async ({