Skip to content

Commit

Permalink
push error into current test
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed May 4, 2020
1 parent d612eab commit 2e6b642
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

exports[`print correct error message with nested test definitions inside describe 1`] = `
FAIL __tests__/nestedTestWithinDescribe.js
in describe
✕ outer test
● Test suite failed to run
● in describe › outer test
Tests cannot be nested. Test "inner test" cannot run because it is nested within "outer test".
Expand All @@ -21,9 +22,9 @@ FAIL __tests__/nestedTestWithinDescribe.js

exports[`print correct error message with nested test definitions outside describe 1`] = `
FAIL __tests__/nestedTestOutsideDescribe.js
✕ outer test
● Test suite failed to run
● outer test
Tests cannot be nested. Test "inner test" cannot run because it is nested within "outer test".
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-circus/src/eventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const eventHandler: Circus.EventHandler = (
const {currentDescribeBlock, currentlyRunningTest} = state;

if (currentlyRunningTest) {
state.unhandledErrors.push(
currentlyRunningTest.errors.push(
new Error(
`Cannot nest a describe inside a test. Describe block "${blockName}" cannot run because it is nested within "${currentlyRunningTest.name}".`,
),
Expand Down Expand Up @@ -97,7 +97,7 @@ const eventHandler: Circus.EventHandler = (
const {asyncError, fn, hookType: type, timeout} = event;

if (currentlyRunningTest) {
state.unhandledErrors.push(
currentlyRunningTest.errors.push(
new Error(
`Hooks cannot be defined inside tests. Hook of type "${type}" is nested within "${currentlyRunningTest.name}".`,
),
Expand All @@ -121,7 +121,7 @@ const eventHandler: Circus.EventHandler = (
const {asyncError, fn, mode, testName: name, timeout} = event;

if (currentlyRunningTest) {
state.unhandledErrors.push(
currentlyRunningTest.errors.push(
new Error(
`Tests cannot be nested. Test "${name}" cannot run because it is nested within "${currentlyRunningTest.name}".`,
),
Expand Down

0 comments on commit 2e6b642

Please sign in to comment.