cypress-cucumber-preprocessor: Fails due to Uncaught TypeError: Cannot read property 'native' of undefined

I haven’t made any changes to my projects except running yarn install, but now I can’t run any tests using Cucumber, while normal Cypress tests run fine.

I tested creating the Google example files and get the same error.

An uncaught error was detected outside of a test: Uncaught TypeError: Cannot read property ‘native’ of undefined.

Here’s the full error log; ` Running: Google.feature (1 of 1)

  1. An uncaught error was detected outside of a test

0 passing (193ms) 1 failing

  1. An uncaught error was detected outside of a test: Uncaught TypeError: Cannot read property ‘native’ of undefined

This error originated from your test code, not from Cypress.

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

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure. at Object.<anonymous> (http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:59549:35) at Object.361…/caller.js (http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:59835:4) at o (http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:1:265) at http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:1:316 at Object.360…/lib/async (http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:59533:13) at o (http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:1:265) at http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:1:316 at Object.<anonymous> (http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:16149:16) at Object.178.bluebird (http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:16155:4) at o (http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:1:265) at http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:1:316 at Object.177…/formatter/builder (http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:15896:26) at o (http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:1:265) at http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:1:316 at Object.206…/cli (http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:18507:12) at o (http://localhost:35739/__cypress/tests?p=cypress/integration/Google.feature-026:1:265) `

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 22

Commits related to this issue

Most upvoted comments

Looks like the issue happens since this change in browserify resolve

https://github.com/browserify/resolve/commit/535ec22acf6d5cc4fa3665ab6dbb6755519e6deb#diff-688ede0ee2da1fa3d89f2fc485f39273R8

typeof fs.realpath.native === 'function' ? fs.realpath.native : fs.realpath;

fs.realpath is undefined

I’m digging into how to pinpoint that version to an older versoin for us or if there is something else we can do

🎉 This issue has been resolved in version 2.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lgandecki confirmed this fixes it! I added:

    "resolve": "1.15.1",

to our package.json resolutions field and now it works:

Screen Shot 2020-04-16 at 10 54 21 AM

As @cellog mentions above, adding

"resolutions":  {
    "resolve": "1.15.1"
}

in your package.json should help for now.

I’ve also opened a PR for more permanent solution:

https://github.com/browserify/resolve/pull/220

If you think it’s a correct change please “vote” there so we can get it in faster 😃 Thanks!

Either way, I’ll have a patch out to avoid this error for resolve in the next 10 hours.

@ljharb thanks for stopping by. 😃 That portion of the code runs and fails in the browser not in node. We are not mocking it in any way. I thought that changing the sync/async modules of resolve package would be a quick and safe change.

Anyway - Thanks to your comment I went back to the code to take another look. I noticed it was the import of cucumber that was causing the failure. Even if we import “pure” functionality of cucumber, requiring the main cucumber module that reexports its internals and APIs brings a lot of baggage, including it’s cli, which brings bluebird, which brings the resolve package that now fails in the browser. When I changed all the cucumber imports to point to the files we actually need it clicked. And it will be probably be much faster as well. So definitely a win. I’d hope for some kind of a treeshaking as I’m not that comfortable with relying on a specific structure of a 3rd party package, but this will have to do for now.

I will release a fix shortly.

Are you mocking out fs? fs.realpath has been in node since v0.1.31 - if your fs implementation lacks it, then it’s broken. The solution is to fix your fs implementation.