Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to skip tests asynchronously in jest-circus, closes #8604 #9944

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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