Skip to content

Commit 5c3fc51

Browse files
committed
build basic async skip functionality
1 parent 649796d commit 5c3fc51

File tree

1 file changed

+11
-2
lines changed
  • packages/jest-circus/src

1 file changed

+11
-2
lines changed

packages/jest-circus/src/run.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,14 @@ const _runTestsForDescribeBlock = async (
8282

8383
const _runTest = async (test: Circus.TestEntry): Promise<void> => {
8484
await dispatch({name: 'test_start', test});
85-
const testContext = Object.create(null);
85+
86+
const testContext: Circus.TestContext = {};
87+
testContext.asyncSkipped = false;
88+
testContext.skip = async () => {
89+
testContext.asyncSkipped = true;
90+
await dispatch({name: 'test_skip', test});
91+
};
92+
8693
const {hasFocusedTests, testNamePattern} = getState();
8794

8895
const isSkipped =
@@ -120,7 +127,9 @@ const _runTest = async (test: Circus.TestEntry): Promise<void> => {
120127
// `afterAll` hooks should not affect test status (pass or fail), because if
121128
// we had a global `afterAll` hook it would block all existing tests until
122129
// this hook is executed. So we dispatch `test_done` right away.
123-
await dispatch({name: 'test_done', test});
130+
if (!testContext.asyncSkipped) {
131+
await dispatch({name: 'test_done', test});
132+
}
124133
};
125134

126135
const _callCircusHook = async ({

0 commit comments

Comments
 (0)