question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Cannot set property 'err' of undefined" error occurs in place of other errors during automatic test-reruns on file save.

See original GitHub issue

Current behavior:

When running tests locally through cypress open, and when interrupting tests by saving files (forcing a re-run), any failures occurred during the run can trigger this message:

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. Learn more

The error is not really originating from the application; it’s occurring within hookFailed at https://github.com/cypress-io/cypress/blob/4cfcae28f097e013ffe7dc7419905eccf1022709/packages/driver/src/cypress/runner.js#L526. Both getTest() and getTestFromHookOrFindTest(hook) end up returning undefined.

I’ve seen this on two very different projects.

  • At work, which is a custom server + Webpack setup, webpack/React, running on MacOS.
  • At home, on a personal project running Next.js, running on Windows (Powershell). This project is linked below.

Desired behavior:

The test fails with the normal readable stack trace.

Test code to reproduce

This is easily reproducible on this project (created a branch with a failing spec): https://github.com/primitiveconcept/ludumdare46/tree/cypress/err-of-undefined/client

  • Run npm run cy:dev for server + Cypress
  • Run the filesystem.spec.ts spec
  • Save the filesystem.spec.ts while the test is running. Reproduces around 25% of the time, may require a few tries.

If needed, I can try to come up with a minimal reproduction, but this isn’t a very complex project. The server isn’t required for the tests.

Versions

Cypress versions: Can reproduce on 4.9.0. Cannot reproduce on 4.5.0. Other versions are unstable for various reasons on the example project. At work, this started occurring on 4.6.0. OS: MacOS + Windows Browser: Chrome + Electron

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:17
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
crfrolikcommented, Jul 15, 2020

The bug is annoying, but I’m more concerned that the error message is lying to us, implying that the error came from our code when it really came from cypress. Should there be another issue to address that?

4reactions
kucebcommented, Aug 4, 2020

I’m working on this. We might have already fixed as part of https://github.com/cypress-io/cypress/pull/8113 (unfortunately didn’t make it into last release), and I’m working on getting a reproducible test case to verify

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mobx cannot set property '@observable' of undefined when ...
Im having an issue with saving JSON-Image-Files to mobx observables as follows. ... Why cant I assign the Array with Image-Objects to this ......
Read more >
Component Reference - Apache JMeter - User's Manual
Several test elements use JMeter properties to control their behaviour. These properties are normally resolved when the class is loaded.
Read more >
Uncaught TypeError: Cannot set property
In JavaScript if a variable has been declared, but has not been assigned a value, is automatically assigned the value undefined.
Read more >
How to solve the 'cannot set property of undefined' issue on ...
In JavaScript almost everything is an object, null and undefined are exception. if a variable has been declared, but has not been assigned...
Read more >
ModelSim PE User's Manual
TRADEMARKS: The trademarks, logos and service marks ("Marks") used herein are the property of. Mentor Graphics Corporation or other third parties. No one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found