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 1, 2020
1 parent 649796d commit e903535
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/jest-circus/src/run.ts
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.canceled = 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 e903535

Please sign in to comment.