Skip to content

Commit

Permalink
fix: give proper error message when err.stack is undefined (#5313)
Browse files Browse the repository at this point in the history
* fix: give proper error message when err.stack is undefined

* fix lint

* update snapshot

* update test to fail w/o src changes
  • Loading branch information
kuceb authored and flotwig committed Nov 8, 2019
1 parent 1466f7c commit 6c39d2e
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/driver/src/cypress/cy.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ create = (specWindow, Cypress, Cookies, state, config, log) ->
## since this failed this means that a
## specific command failed and we should
## highlight it in red or insert a new command

err.name = err.name || 'CypressError'
errors.commandRunningFailed(err)

fail(err, state("runnable"))
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cypress/utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = {
## because the browser has a cached
## dynamic stack getter that will
## not be evaluated later
stack = err.stack
stack = err.stack or ''

## preserve message
## and toString
Expand Down
76 changes: 76 additions & 0 deletions packages/server/__snapshots__/3_issue_1669_spec.coffee.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
exports['e2e issue 2891 passes 1'] = `
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (issue_1669_spec.js) │
│ Searched: cypress/integration/issue_1669_spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: issue_1669_spec.js (1 of 1)
issue-1669 undefined err.stack in beforeEach hook
1) "before each" hook for "cy.setCookie should fail with correct error"
0 passing
1 failing
1) issue-1669 undefined err.stack in beforeEach hook "before each" hook for "cy.setCookie should fail with correct error":
some error, without stack
Because this error occurred during a 'before each' hook we are skipping the remaining tests in the current suite: 'issue-1669 undefined err.st...'
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 0 │
│ Failing: 1 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 1 │
│ Video: true │
│ Duration: X seconds │
│ Spec Ran: issue_1669_spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Screenshots)
- /XXX/XXX/XXX/cypress/screenshots/issue_1669_spec.js/issue-1669 undefined err.sta (1280x720)
ck in beforeEach hook -- cy.setCookie should fail with correct error -- before e
ach hook (failed).png
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: /XXX/XXX/XXX/cypress/videos/issue_1669_spec.js.mp4 (X second)
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ issue_1669_spec.js XX:XX 1 - 1 - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✖ 1 of 1 failed (100%) XX:XX 1 - 1 - -
`
15 changes: 15 additions & 0 deletions packages/server/test/e2e/3_issue_1669_spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
e2e = require("../support/helpers/e2e")
Fixtures = require("../support/helpers/fixtures")

describe "e2e issue 2891", ->
e2e.setup()

## https://github.com/cypress-io/cypress/issues/2891

it "passes", ->
e2e.exec(@, {
spec: "issue_1669_spec.js"
snapshot: true
browser: 'chrome'
expectedExitCode: 1
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
describe('issue-1669 undefined err.stack in beforeEach hook', () => {
beforeEach(() => {
const errorWithoutStack = new Error('some error, without stack')

delete errorWithoutStack.stack
throw errorWithoutStack
})

it('cy.setCookie should fail with correct error', () => {
expect(true).ok
})
})

4 comments on commit 6c39d2e

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6c39d2e Nov 8, 2019

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/3.6.1/linux-x64/circle-develop-6c39d2ebfd898a5161d0969c321bf82e558d0d90-188655/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.6.1/circle-develop-6c39d2ebfd898a5161d0969c321bf82e558d0d90-188644/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6c39d2e Nov 8, 2019

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.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.6.1/win32-x64/appveyor-develop-6c39d2ebfd898a5161d0969c321bf82e558d0d90-28726225/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.6.1/win32-x64/appveyor-develop-6c39d2ebfd898a5161d0969c321bf82e558d0d90-28726225/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6c39d2e Nov 8, 2019

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.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.6.1/win32-ia32/appveyor-develop-6c39d2ebfd898a5161d0969c321bf82e558d0d90-28726225/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.6.1/win32-ia32/appveyor-develop-6c39d2ebfd898a5161d0969c321bf82e558d0d90-28726225/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6c39d2e Nov 8, 2019

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/3.6.1/darwin-x64/circle-develop-6c39d2ebfd898a5161d0969c321bf82e558d0d90-188742/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.6.1/circle-develop-6c39d2ebfd898a5161d0969c321bf82e558d0d90-188658/cypress.tgz

Please sign in to comment.