mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-22 15:12:27 -05:00
fix hanging on nested hook error
This commit is contained in:
@@ -1010,12 +1010,15 @@ const create = (specWindow, mocha, Cypress, cy) => {
|
||||
}
|
||||
|
||||
const maybeHandleRetry = (runnable, err) => {
|
||||
if (!err) return
|
||||
|
||||
const r = runnable
|
||||
const isHook = r.type === 'hook'
|
||||
const isTest = r.type === 'test'
|
||||
const test = getTest() || getTestFromHook(runnable, getTestById)
|
||||
const isBeforeEachHook = isHook && !!r.hookName.match(/before each/)
|
||||
const isAfterEachHook = isHook && !!r.hookName.match(/after each/)
|
||||
const hookName = isHook && getHookName(r)
|
||||
const isBeforeEachHook = isHook && !!hookName.match(/before each/)
|
||||
const isAfterEachHook = isHook && !!hookName.match(/after each/)
|
||||
const retryAbleRunnable = isTest || isBeforeEachHook || isAfterEachHook
|
||||
const willRetry = (test._currentRetry < test._retries) && retryAbleRunnable
|
||||
|
||||
@@ -1196,8 +1199,8 @@ const create = (specWindow, mocha, Cypress, cy) => {
|
||||
|
||||
const isHook = runnable.type === 'hook'
|
||||
|
||||
const isAfterEachHook = isHook && runnable.hookName.match(/after each/)
|
||||
const isBeforeEachHook = isHook && runnable.hookName.match(/before each/)
|
||||
const isAfterEachHook = isHook && hookName.match(/after each/)
|
||||
const isBeforeEachHook = isHook && hookName.match(/before each/)
|
||||
|
||||
// if we've been told to skip hooks at a certain nested level
|
||||
// this happens if we're handling a runnable that is going to retry due to failing in a hook
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
const { createCypress } = require('../support/helpers')
|
||||
const { runIsolatedCypress } = createCypress()
|
||||
|
||||
describe('issue-8350', () => {
|
||||
it('does not hang on nested hook', () => {
|
||||
runIsolatedCypress(() => {
|
||||
before(() => {
|
||||
beforeEach(() => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('ae inside be', () => {
|
||||
it('t1', () => {
|
||||
//
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -237,11 +237,6 @@ function createCypress (defaultOptions = {}) {
|
||||
if (testsInOwnFile) return
|
||||
|
||||
generateMochaTestsForWin(specWindow, mochaTestsOrFile)
|
||||
specWindow.before = () => {}
|
||||
specWindow.beforeEach = () => {}
|
||||
specWindow.afterEach = () => {}
|
||||
specWindow.after = () => {}
|
||||
specWindow.describe = () => {}
|
||||
})
|
||||
|
||||
cy.stub(autCypress, 'run').snapshot(enableStubSnapshots).log(false).callsFake(runIsolatedCypress)
|
||||
|
||||
Reference in New Issue
Block a user