Skip to content

Commit

Permalink
build basic async skip functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLoh committed May 27, 2020
1 parent 649796d commit 5c3fc51
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/jest-circus/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ const _runTestsForDescribeBlock = async (

const _runTest = async (test: Circus.TestEntry): Promise<void> => {
await dispatch({name: 'test_start', test});
const testContext = Object.create(null);

const testContext: Circus.TestContext = {};
testContext.asyncSkipped = false;
testContext.skip = async () => {
testContext.asyncSkipped = true;
await dispatch({name: 'test_skip', test});
};

const {hasFocusedTests, testNamePattern} = getState();

const isSkipped =
Expand Down Expand Up @@ -120,7 +127,9 @@ const _runTest = async (test: Circus.TestEntry): Promise<void> => {
// `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 ({
Expand Down

0 comments on commit 5c3fc51

Please sign in to comment.