Skip to content

Commit

Permalink
[WIP] try to fix circus as well
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed May 27, 2018
1 parent 5f8e7b0 commit f65ed9e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
22 changes: 11 additions & 11 deletions packages/jest-circus/src/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {

import {getState, dispatch} from './state';
import {
callAsyncFn,
callAsyncCircusFn,
getAllHooksForDescribe,
getEachHooksForTest,
getTestID,
Expand All @@ -44,7 +44,7 @@ const _runTestsForDescribeBlock = async (describeBlock: DescribeBlock) => {
const {beforeAll, afterAll} = getAllHooksForDescribe(describeBlock);

for (const hook of beforeAll) {
await _callHook({describeBlock, hook});
await _callCircusHook({describeBlock, hook});
}
for (const test of describeBlock.tests) {
await _runTest(test);
Expand All @@ -55,7 +55,7 @@ const _runTestsForDescribeBlock = async (describeBlock: DescribeBlock) => {
}

for (const hook of afterAll) {
await _callHook({describeBlock, hook});
await _callCircusHook({describeBlock, hook});
}
dispatch({describeBlock, name: 'run_describe_finish'});
};
Expand Down Expand Up @@ -83,13 +83,13 @@ const _runTest = async (test: TestEntry): Promise<void> => {
// hooks after that.
break;
}
await _callHook({hook, test, testContext});
await _callCircusHook({hook, test, testContext});
}

await _callTest(test, testContext);
await _callCircusTest(test, testContext);

for (const hook of afterEach) {
await _callHook({hook, test, testContext});
await _callCircusHook({hook, test, testContext});
}

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

const _callHook = ({
const _callCircusHook = ({
hook,
test,
describeBlock,
Expand All @@ -111,14 +111,14 @@ const _callHook = ({
}): Promise<mixed> => {
dispatch({hook, name: 'hook_start'});
const timeout = hook.timeout || getState().testTimeout;
return callAsyncFn(hook.fn, testContext, {isHook: true, timeout})
return callAsyncCircusFn(hook.fn, testContext, {isHook: true, timeout})
.then(() => dispatch({describeBlock, hook, name: 'hook_success', test}))
.catch(error =>
dispatch({describeBlock, error, hook, name: 'hook_failure', test}),
);
};

const _callTest = async (
const _callCircusTest = (
test: TestEntry,
testContext: TestContext,
): Promise<void> => {
Expand All @@ -128,10 +128,10 @@ const _callTest = async (

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

await callAsyncFn(test.fn, testContext, {isHook: false, timeout})
return callAsyncCircusFn(test.fn, testContext, {isHook: false, timeout})
.then(() => dispatch({name: 'test_fn_success', test}))
.catch(error => dispatch({error, name: 'test_fn_failure', test}));
};
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const _makeTimeoutMessage = (timeout, isHook) =>
// the original values in the variables before we require any files.
const {setTimeout, clearTimeout} = global;

export const callAsyncFn = (
export const callAsyncCircusFn = (
fn: AsyncFn,
testContext: ?TestContext,
{
Expand Down
3 changes: 3 additions & 0 deletions packages/jest-cli/src/get_node_handles.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export default function collectHandles(): () => Array<Error> {

if (
error.stack.includes('Runtime.requireModule') ||
(error.stack.includes('callAsyncCircusFn') &&
(error.stack.includes('_callCircusTest') ||
error.stack.includes('_callCircusHook'))) ||
error.stack.includes('asyncJestTest') ||
error.stack.includes('asyncJestLifecycle')
) {
Expand Down

0 comments on commit f65ed9e

Please sign in to comment.