Skip to content

Commit f65ed9e

Browse files
committed
[WIP] try to fix circus as well
1 parent 5f8e7b0 commit f65ed9e

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

packages/jest-circus/src/run.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import type {
1717

1818
import {getState, dispatch} from './state';
1919
import {
20-
callAsyncFn,
20+
callAsyncCircusFn,
2121
getAllHooksForDescribe,
2222
getEachHooksForTest,
2323
getTestID,
@@ -44,7 +44,7 @@ const _runTestsForDescribeBlock = async (describeBlock: DescribeBlock) => {
4444
const {beforeAll, afterAll} = getAllHooksForDescribe(describeBlock);
4545

4646
for (const hook of beforeAll) {
47-
await _callHook({describeBlock, hook});
47+
await _callCircusHook({describeBlock, hook});
4848
}
4949
for (const test of describeBlock.tests) {
5050
await _runTest(test);
@@ -55,7 +55,7 @@ const _runTestsForDescribeBlock = async (describeBlock: DescribeBlock) => {
5555
}
5656

5757
for (const hook of afterAll) {
58-
await _callHook({describeBlock, hook});
58+
await _callCircusHook({describeBlock, hook});
5959
}
6060
dispatch({describeBlock, name: 'run_describe_finish'});
6161
};
@@ -83,13 +83,13 @@ const _runTest = async (test: TestEntry): Promise<void> => {
8383
// hooks after that.
8484
break;
8585
}
86-
await _callHook({hook, test, testContext});
86+
await _callCircusHook({hook, test, testContext});
8787
}
8888

89-
await _callTest(test, testContext);
89+
await _callCircusTest(test, testContext);
9090

9191
for (const hook of afterEach) {
92-
await _callHook({hook, test, testContext});
92+
await _callCircusHook({hook, test, testContext});
9393
}
9494

9595
// `afterAll` hooks should not affect test status (pass or fail), because if
@@ -98,7 +98,7 @@ const _runTest = async (test: TestEntry): Promise<void> => {
9898
dispatch({name: 'test_done', test});
9999
};
100100

101-
const _callHook = ({
101+
const _callCircusHook = ({
102102
hook,
103103
test,
104104
describeBlock,
@@ -111,14 +111,14 @@ const _callHook = ({
111111
}): Promise<mixed> => {
112112
dispatch({hook, name: 'hook_start'});
113113
const timeout = hook.timeout || getState().testTimeout;
114-
return callAsyncFn(hook.fn, testContext, {isHook: true, timeout})
114+
return callAsyncCircusFn(hook.fn, testContext, {isHook: true, timeout})
115115
.then(() => dispatch({describeBlock, hook, name: 'hook_success', test}))
116116
.catch(error =>
117117
dispatch({describeBlock, error, hook, name: 'hook_failure', test}),
118118
);
119119
};
120120

121-
const _callTest = async (
121+
const _callCircusTest = (
122122
test: TestEntry,
123123
testContext: TestContext,
124124
): Promise<void> => {
@@ -128,10 +128,10 @@ const _callTest = async (
128128

129129
if (test.errors.length) {
130130
// We don't run the test if there's already an error in before hooks.
131-
return;
131+
return Promise.resolve();
132132
}
133133

134-
await callAsyncFn(test.fn, testContext, {isHook: false, timeout})
134+
return callAsyncCircusFn(test.fn, testContext, {isHook: false, timeout})
135135
.then(() => dispatch({name: 'test_fn_success', test}))
136136
.catch(error => dispatch({error, name: 'test_fn_failure', test}));
137137
};

packages/jest-circus/src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ const _makeTimeoutMessage = (timeout, isHook) =>
140140
// the original values in the variables before we require any files.
141141
const {setTimeout, clearTimeout} = global;
142142

143-
export const callAsyncFn = (
143+
export const callAsyncCircusFn = (
144144
fn: AsyncFn,
145145
testContext: ?TestContext,
146146
{

packages/jest-cli/src/get_node_handles.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export default function collectHandles(): () => Array<Error> {
2525

2626
if (
2727
error.stack.includes('Runtime.requireModule') ||
28+
(error.stack.includes('callAsyncCircusFn') &&
29+
(error.stack.includes('_callCircusTest') ||
30+
error.stack.includes('_callCircusHook'))) ||
2831
error.stack.includes('asyncJestTest') ||
2932
error.stack.includes('asyncJestLifecycle')
3033
) {

0 commit comments

Comments
 (0)