Skip to content

Commit

Permalink
Merge pull request #8379 from cypress-io/fix-nested-hooks-error
Browse files Browse the repository at this point in the history
  • Loading branch information
kuceb authored Aug 24, 2020
2 parents eac7859 + 2ee35a9 commit 96c8747
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
11 changes: 7 additions & 4 deletions packages/driver/src/cypress/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions packages/runner/cypress/integration/issues/issue-8350.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { createCypress } = require('../../support/helpers')
const { runIsolatedCypress } = createCypress()

// https://github.com/cypress-io/cypress/issues/8350
describe('issue-8350', () => {
it('does not hang on nested hook', () => {
runIsolatedCypress(() => {
before(() => {
beforeEach(() => {
})
})

describe('s1', () => {
it('t1', () => {
//
})
})
})
})
})
5 changes: 0 additions & 5 deletions packages/runner/cypress/support/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

4 comments on commit 96c8747

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 96c8747 Aug 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/linux-x64/circle-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-430472/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/circle-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-430422/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 96c8747 Aug 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-x64/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/5.0.1/win32-x64/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-x64/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-x64/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.zip npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 96c8747 Aug 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-ia32/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/5.0.1/win32-ia32/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-ia32/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-ia32/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.zip npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-34827946/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 96c8747 Aug 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/darwin-x64/circle-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-430571/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/circle-develop-96c8747c9a131f004462d78557bdf62b835f0d6a-430504/cypress.tgz

Please sign in to comment.