Skip to content

Commit

Permalink
fix(runner): Cannot set property 'err' of undefined on spec rerun d…
Browse files Browse the repository at this point in the history
…ue to file changes (#8193)
  • Loading branch information
kuceb committed Aug 6, 2020
1 parent 2156e3e commit 9c930a2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 9 deletions.
16 changes: 10 additions & 6 deletions packages/driver/src/cypress/runner.js
Expand Up @@ -832,7 +832,6 @@ const create = (specWindow, mocha, Cypress, cy) => {
}

// hold onto the _runnables for faster lookup later
let _stopped = false
let _test = null
let _tests = []
let _testsById = {}
Expand Down Expand Up @@ -932,8 +931,13 @@ const create = (specWindow, mocha, Cypress, cy) => {

return _runner.run((failures) => {
// if we happen to make it all the way through
// the run, then just set _stopped to true here
_stopped = true
// the run, then just set _runner.stopped to true here
_runner.stopped = true

// remove all the listeners
// so no more events fire
// since a test failure may 'leak' after a run completes
_runner.removeAllListeners()

// TODO this functions is not correctly
// synchronized with the 'end' event that
Expand Down Expand Up @@ -1183,11 +1187,11 @@ const create = (specWindow, mocha, Cypress, cy) => {
},

stop () {
if (_stopped) {
if (_runner.stopped) {
return
}

_stopped = true
_runner.stopped = true

// abort the run
_runner.abort()
Expand All @@ -1200,7 +1204,7 @@ const create = (specWindow, mocha, Cypress, cy) => {

// remove all the listeners
// so no more events fire
return _runner.removeAllListeners()
_runner.removeAllListeners()
},

getDisplayPropsForLog: $Log.getDisplayProps,
Expand Down
31 changes: 31 additions & 0 deletions packages/runner/cypress/integration/reporter.hooks.spec.js
Expand Up @@ -119,4 +119,35 @@ describe('hooks', function () {
})
})
})

// https://github.com/cypress-io/cypress/issues/8189
it('can rerun without timeout error leaking into next run (due to run restart)', () => {
runIsolatedCypress(() => {
const top = window.parent

top.count = top.count || 0

Cypress.config('defaultCommandTimeout', 50)
afterEach(function () {
assert(true, `run ${top.count}`)
})

describe('s1', () => {
it('foo', () => {
cy.once('test:after:run', () => {
if (!top.count) {
requestAnimationFrame(() => {
window.parent.eventManager.reporterBus.emit('runner:restart')
})
}

top.count++
})
})
})
})

// wait until spec has run twice (due to one reload)
cy.window().its('count').should('eq', 2)
})
})
11 changes: 8 additions & 3 deletions packages/runner/cypress/support/helpers.js
Expand Up @@ -188,9 +188,14 @@ function createCypress () {
})
})

cy.spy(cy.state('window').console, 'log').as('console_log')
cy.spy(cy.state('window').console, 'error').as('console_error')

// TODO: clean this up, sinon doesn't like wrapping things multiple times
// and this catches that error
try {
cy.spy(cy.state('window').console, 'log').as('console_log')
cy.spy(cy.state('window').console, 'error').as('console_error')
} catch (_e) {
// console was already wrapped, noop
}
onInitializedListeners.forEach((fn) => fn(autCypress))
onInitializedListeners = []

Expand Down

4 comments on commit 9c930a2

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9c930a2 Aug 6, 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.0/linux-x64/circle-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-414253/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/circle-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-414244/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9c930a2 Aug 6, 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.0/win32-x64/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/5.0.0/win32-x64/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/win32-x64/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/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.0/win32-x64/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/cypress.zip npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9c930a2 Aug 6, 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.0/win32-ia32/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/5.0.0/win32-ia32/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/win32-ia32/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/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.0/win32-ia32/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/cypress.zip npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-34509186/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9c930a2 Aug 6, 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.0/darwin-x64/circle-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-414406/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/circle-develop-9c930a27f8c06e58de9ea6c79c1d3329f5585dc7-414271/cypress.tgz

Please sign in to comment.