diff --git a/packages/driver/src/cypress/cy.coffee b/packages/driver/src/cypress/cy.coffee index 0f27bc77ca3..42d471342c1 100644 --- a/packages/driver/src/cypress/cy.coffee +++ b/packages/driver/src/cypress/cy.coffee @@ -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")) diff --git a/packages/driver/src/cypress/utils.coffee b/packages/driver/src/cypress/utils.coffee index 1baf13b13d9..3c1ba00f023 100644 --- a/packages/driver/src/cypress/utils.coffee +++ b/packages/driver/src/cypress/utils.coffee @@ -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 diff --git a/packages/server/__snapshots__/3_issue_1669_spec.coffee.js b/packages/server/__snapshots__/3_issue_1669_spec.coffee.js new file mode 100644 index 00000000000..d36b56f1209 --- /dev/null +++ b/packages/server/__snapshots__/3_issue_1669_spec.coffee.js @@ -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 - - + + +` diff --git a/packages/server/test/e2e/3_issue_1669_spec.coffee b/packages/server/test/e2e/3_issue_1669_spec.coffee new file mode 100644 index 00000000000..0666dc0ef71 --- /dev/null +++ b/packages/server/test/e2e/3_issue_1669_spec.coffee @@ -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 + }) diff --git a/packages/server/test/support/fixtures/projects/e2e/cypress/integration/issue_1669_spec.js b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/issue_1669_spec.js new file mode 100644 index 00000000000..b037b2613f5 --- /dev/null +++ b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/issue_1669_spec.js @@ -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 + }) +})