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.
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.
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)
`
Would you be able to create a simple reproduction in a fresh repository? Also, what version of our plugin do you have installed?
I made this:
repo
It installed the latest version 2.3.0. If run as is, the tests fail. I included another lock file, working_yarn.lock from an earlier project. If it's used with yarn --pure-lock I got it to work. It's also 2.3.0 so perhaps the issue is one of the dependencies.
Thanks a lot! this will be very helpful. I should be able to disect this today:)
Thanks !
Same issue on our project. Everything was working fine several hours ago.
well, that just became even higher priority.. ;)
On our project :
cypress-cucumber-preprocessor :
package.json : "^1.19.0"
package-lock.json : "1.19.2"
can confirm this is blocking everything. I am using Cypress 4.2.0, with this webpack config:
module.exports = {
resolve: {
extensions: [".ts", ".js"],
},
node: { fs: "empty", child_process: "empty", readline: "empty" },
module: {
rules: [
{
test: /\.ts$/,
exclude: [/node_modules/],
use: [
{
loader: "ts-loader",
},
],
},
{
test: /\.feature$/,
use: [
{
loader: "cypress-cucumber-preprocessor/loader",
},
],
},
{
test: /\.features$/,
use: [
{
loader: "cypress-cucumber-preprocessor/lib/featuresLoader",
},
],
},
],
},
};
NOTE: I tried removing all Typescript and it still fails instantly on parsing .feature files.
plugins.js:
/* eslint-disable @typescript-eslint/no-var-requires */
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const fs = require("fs");
const wp = require("@cypress/webpack-preprocessor");
const coverageTask = require("@cypress/code-coverage/task");
const webpackConfig = require("../webpack.config");
const autoRecord = require("./auto-record/plugin");
module.exports = (on, config) => {
const options = {
webpackOptions: webpackConfig,
};
on("file:preprocessor", wp(options));
on("task", coverageTask);
autoRecord(on, config, fs);
};
cypress.json:
{
"baseUrl": "http://0.0.0.0:8085",
"reporter": "junit",
"ignoreTestFiles": [
"*.hot-update.js",
"**/integration/**/*"
],
"testFiles": "**/*.{feature,features,ts}",
"integrationFolder": "cypress/e2e",
"videosFolder": "cypress/e2e/videos",
"sceenshotsFolder": "cypress/e2e/screenshots",
"viewportHeight": 1000,
"viewportWidth": 1400,
"reporterOptions": {
"mochaFile": "results/junit-[hash].xml"
}
}
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
@lgandecki confirmed this fixes it! I added:
"resolve": "1.15.1",
to our package.json resolutions field and now it works:

great! We might need to add this to the README.md for now..
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!
It might be worth mentioning in the notes that in the scripts you need to add a preinstall step in your package.json assuming you are running npm and you don't have one already:
"scripts": {
"preinstall": "npx npm-force-resolutions"
}
@mramsden that is for npm users. yarn uses resolutions natively. Definitely worth mentioning with a link to the docs for both solutions. Thanks so so much for the quick resolution!
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.
@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.
Either way, I鈥檒l have a patch out to avoid this error for resolve in the next 10 hours.
:tada: This issue has been resolved in version 2.3.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
@lgandecki I get the same error with v2.3.1
Uncaught TypeError: Cannot read property 'native' of undefined
@id-dan works for me in the repro repo. Please verify your version with
grep version node_modules/cypress-cucumber-preprocessor/package.json
remove your yarn/package lock , remove your node_modules, make sure your version is specified as
"cypress-cucumber-preprocessor": "2.3.1"
reinstall everything and give it another try
thank you, @lgandecki
works after removing and reinstall - node_modules 馃槑
Thank you @lgandecki
it works nicely after removing lockfile and running yarn.
resolve v1.16.1 is released, which avoids this error.
Most helpful comment
Looks like the issue happens since this change in browserify resolve
https://github.com/browserify/resolve/commit/535ec22acf6d5cc4fa3665ab6dbb6755519e6deb#diff-688ede0ee2da1fa3d89f2fc485f39273R8
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