diff --git a/e2e/__tests__/__snapshots__/nestedTestDefinitions.test.ts.snap b/e2e/__tests__/__snapshots__/nestedTestDefinitions.test.ts.snap index 95a191204304..daba859d0094 100644 --- a/e2e/__tests__/__snapshots__/nestedTestDefinitions.test.ts.snap +++ b/e2e/__tests__/__snapshots__/nestedTestDefinitions.test.ts.snap @@ -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". @@ -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". diff --git a/packages/jest-circus/src/eventHandler.ts b/packages/jest-circus/src/eventHandler.ts index b3b0a45fcf0c..590e66ca3a13 100644 --- a/packages/jest-circus/src/eventHandler.ts +++ b/packages/jest-circus/src/eventHandler.ts @@ -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}".`, ), @@ -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}".`, ), @@ -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}".`, ),