Skip to content

Commit

Permalink
fix(*): fixed issues in jest-circus & jest-jasmine related to issue j…
Browse files Browse the repository at this point in the history
  • Loading branch information
sarathps93 committed Nov 10, 2020
1 parent bafb4eb commit 149a2e3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
24 changes: 17 additions & 7 deletions packages/jest-circus/src/run.ts
Expand Up @@ -34,8 +34,12 @@ const _runTestsForDescribeBlock = async (
await dispatch({describeBlock, name: 'run_describe_start'});
const {beforeAll, afterAll} = getAllHooksForDescribe(describeBlock);

for (const hook of beforeAll) {
await _callCircusHook({describeBlock, hook});
const isSkipped = describeBlock.mode === 'skip';

if (!isSkipped) {
for (const hook of beforeAll) {
await _callCircusHook({describeBlock, hook});
}
}

// Tests that fail and are retried we run after other tests
Expand All @@ -50,7 +54,7 @@ const _runTestsForDescribeBlock = async (
}
case 'test': {
const hasErrorsBeforeTestRun = child.errors.length > 0;
await _runTest(child);
await _runTest(child, isSkipped);

if (
hasErrorsBeforeTestRun === false &&
Expand All @@ -72,24 +76,30 @@ const _runTestsForDescribeBlock = async (
// Clear errors so retries occur
await dispatch({name: 'test_retry', test});

await _runTest(test);
await _runTest(test, isSkipped);
numRetriesAvailable--;
}
}

for (const hook of afterAll) {
await _callCircusHook({describeBlock, hook});
if (!isSkipped) {
for (const hook of afterAll) {
await _callCircusHook({describeBlock, hook});
}
}

await dispatch({describeBlock, name: 'run_describe_finish'});
};

const _runTest = async (test: Circus.TestEntry): Promise<void> => {
const _runTest = async (
test: Circus.TestEntry,
parentSkipped: boolean,
): Promise<void> => {
await dispatch({name: 'test_start', test});
const testContext = Object.create(null);
const {hasFocusedTests, testNamePattern} = getState();

const isSkipped =
parentSkipped ||
test.mode === 'skip' ||
(hasFocusedTests && test.mode !== 'only') ||
(testNamePattern && !testNamePattern.test(getTestID(test)));
Expand Down
4 changes: 3 additions & 1 deletion packages/jest-jasmine2/src/jasmine/Env.ts
Expand Up @@ -611,7 +611,8 @@ export default function (j$: Jasmine) {
() => {},
currentDeclarationSuite,
);
spec.todo();
if (currentDeclarationSuite.markedPending) spec.pend();
else spec.todo();
currentDeclarationSuite.addChild(spec);
return spec;
};
Expand All @@ -625,6 +626,7 @@ export default function (j$: Jasmine) {
);
currentDeclarationSuite.addChild(spec);
focusedRunnables.push(spec.id);
if (currentDeclarationSuite.markedPending) spec.pend();
unfocusAncestor();
return spec;
};
Expand Down
9 changes: 5 additions & 4 deletions packages/jest-jasmine2/src/treeProcessor.ts
Expand Up @@ -65,10 +65,11 @@ export default function treeProcessor(options: Options): void {
}

function hasNoEnabledTest(node: TreeNode): boolean {
if (node.children) {
return node.children.every(hasNoEnabledTest);
}
return node.disabled || node.markedPending;
return (
node.disabled ||
node.markedPending ||
(!!node.children && node.children.every(hasNoEnabledTest))
);
}

function wrapChildren(node: TreeNode, enabled: boolean) {
Expand Down

0 comments on commit 149a2e3

Please sign in to comment.