Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when taking screenshots in afterEach function #7860

Closed
bluepioupiou opened this issue Jun 30, 2020 · 6 comments
Closed

Error when taking screenshots in afterEach function #7860

bluepioupiou opened this issue Jun 30, 2020 · 6 comments
Labels
type: duplicate This issue or pull request already exists

Comments

@bluepioupiou
Copy link

bluepioupiou commented Jun 30, 2020

Current behavior:

When i'm trying to take a screenshot in a afterEach method, the first time averything went fine, but when I reload the test the screenshot fails with the following error 馃憤

TypeError
The following error originated from your application code, not from Cypress.

  > Cannot set property 'err' of undefined

When I refresh again it works and when I refresh it fails, etc. It's not every one of two but almost...

image

Desired behavior:

I would like to be able use screenshot method in afterEach without issues

Test code to reproduce

/// <reference types="cypress" />

describe("Test", function() {
  afterEach(function() {
    cy.screenshot();
  });

  it("Test", function() {
    cy.visit("http://google.com");
  });
});

Versions

1.4.8

Chrome

@jennifer-shehane
Copy link
Member

@bluepioupiou I'm not able to recreate this with the code provided in Cypress 4.9.0 - Chrome 83.0.4103.116.

  • How are you 'reloading' the test?
  • Do you have any other code in your support/index.js? plugins/index.js? cypress.json?
  • What version of Cypress are you using? cypress info will print this.
  • What version of Chrome are you using?

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Jul 1, 2020
@bluepioupiou
Copy link
Author

  • Either by using the reload all test button in the interface or by saving again my test file to trigger it
  • plugin is brand new I didn't change anything inside, cypress.json is simple :
    { "baseUrl": "http://localhost:3002", "chromeWebSecurity": false, "viewportWidth": 1440, "video": false }
  • I juste upgraded to 4.9 and sameresult
  • Chrome is at version 83

I'm pretty sure that if I use cypress with command lines everything will be fine but it's a bit hard to develop with the client version if it failed half of the time

@jennifer-shehane
Copy link
Member

I'm not sure. We'd have to narrow down why this is failing for you and not me. Maybe it's regional? Something about your google page is loading different from mine? It seems to be indicating this error is throwing from Google somewhere. Are there errors in the DevTools?

Screen Shot 2020-07-02 at 2 24 30 PM

@bluepioupiou
Copy link
Author

bluepioupiou commented Jul 2, 2020

No error from DevTool. A I said it's working too on my side, but only half of the time... did you refreshed ? It works every time ? It reallyis when i'm using screenshot in afterEach. If I use it "normally" in each test it's working fine and I can reload as much as I want

What do you need ? Maybe I can share screen to inquiery more precisly ?
Here is my error in detail:

cypress_runner.js:197680 Console was cleared
cypress_runner.js:197677 TypeError: The following error originated from your application code, not from Cypress.

  > Cannot set property 'err' of undefined

When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

This behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.

Because this error occurred during a `after each` hook we are skipping the remaining tests in the current suite: Test
    at hookFailed (https://www.google.com/__cypress/runner/cypress_runner.js:172583:12)
    at Runner.<anonymous> (https://www.google.com/__cypress/runner/cypress_runner.js:172784:14)
    at Runner.emit (https://www.google.com/__cypress/runner/cypress_runner.js:51629:7)
    at Runner.fail (https://www.google.com/__cypress/runner/cypress_runner.js:171708:10)
    at Runner.../driver/node_modules/mocha/lib/runner.js.Runner.failHook (https://www.google.com/__cypress/runner/cypress_runner.js:103740:8)
    at Hook.<anonymous> (https://www.google.com/__cypress/runner/cypress_runner.js:103777:14)
    at Hook.emit (https://www.google.com/__cypress/runner/cypress_runner.js:51624:5)
    at multiple (https://www.google.com/__cypress/runner/cypress_runner.js:103196:12)
    at Hook.done [as callback] (https://www.google.com/__cypress/runner/cypress_runner.js:103210:14)
    at https://www.google.com/__cypress/runner/cypress_runner.js:171759:16
From previous event:
    at run (https://www.google.com/__cypress/runner/cypress_runner.js:167273:19)
    at $Cy.cy.<computed> [as screenshot] (https://www.google.com/__cypress/runner/cypress_runner.js:167725:11)
    at Context.runnable.fn (https://www.google.com/__cypress/runner/cypress_runner.js:167950:21)
    at callFn (https://www.google.com/__cypress/runner/cypress_runner.js:103279:21)
    at Hook.../driver/node_modules/mocha/lib/runnable.js.Runnable.run (https://www.google.com/__cypress/runner/cypress_runner.js:103266:7)
    at https://www.google.com/__cypress/runner/cypress_runner.js:173107:28
From previous event:
    at Object.onRunnableRun (https://www.google.com/__cypress/runner/cypress_runner.js:173095:20)
    at $Cypress.action (https://www.google.com/__cypress/runner/cypress_runner.js:163946:61)
    at Hook.Runnable.run (https://www.google.com/__cypress/runner/cypress_runner.js:171720:13)
    at next (https://www.google.com/__cypress/runner/cypress_runner.js:103781:10)
    at https://www.google.com/__cypress/runner/cypress_runner.js:103825:5
    at timeslice (https://www.google.com/__cypress/runner/cypress_runner.js:97751:27)
logError @ cypress_runner.js:197677
(anonymous) @ cypress_runner.js:197324
emit @ cypress_runner.js:51624
(anonymous) @ cypress_runner.js:181711
emit @ cypress_runner.js:51624
emit @ cypress_runner.js:181754
onPrint @ cypress_runner.js:180622
_onPrintClick @ cypress_runner.js:180627
ca @ cypress_runner.js:59147
ja @ cypress_runner.js:59148
ka @ cypress_runner.js:59148
wa @ cypress_runner.js:59150
Aa @ cypress_runner.js:59151
ya @ cypress_runner.js:59151
Da @ cypress_runner.js:59154
Ad @ cypress_runner.js:59217
Gi @ cypress_runner.js:59383
Kb @ cypress_runner.js:59172
Dd @ cypress_runner.js:59219
(anonymous) @ cypress_runner.js:59384
../../node_modules/scheduler/cjs/scheduler.production.min.js.exports.unstable_runWithPriority @ cypress_runner.js:63524
Ii @ cypress_runner.js:59384
Cd @ cypress_runner.js:59218

@alewolf
Copy link

alewolf commented Jul 31, 2020

Same as this issue: #7874

@jennifer-shehane
Copy link
Member

Duplicate of #7874

@jennifer-shehane jennifer-shehane marked this as a duplicate of #7874 Aug 24, 2020
@jennifer-shehane jennifer-shehane added type: duplicate This issue or pull request already exists and removed stage: needs information Not enough info to reproduce the issue labels Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants