Unable to resolve the fs promise (node events)
See original GitHub issueCurrent behavior
I have upgraded Cypress to version 10.4 and cucumber-cypress-preprocessor to version 11.4.0. As this needed a bundler, I installed the ESbuild dependencies based on the examples given in the project.
Since then, I am receiving error when trying to run any test in the suite. I tried using fs-extra dependency with no luck I also tried replacing fs.readFileSync(file) with fs.promised.readfile using async and wait with no success.
I found a potential fix but not sure how to add it to my project: https://esbuild.github.io/getting-started/#bundling-for-node
Error: Build failed with 1 error: cypress/support/commands/readXlsx.js:2:23: ERROR: Could not resolve “fs” at failureErrorWithLog (/Users/abc/Test Automation Projects/functional-prj/node_modules/esbuild/lib/main.js:1624:15)
Desired behavior
I want the fs promise to work as before. though I had to add a bundler(Esbuild) for preprocessor 11.4 to work, I am still using node as the package manager.
Test code to reproduce
Cypress.Commands.add(“readXlsx”, (file, sheet) => { const fs = require(“fs”); const XLSX = require(“xlsx”);
const read = ({ file, sheet }) => {
const buf = fs.readFileSync(file);
const workbook = XLSX.read(buf, { type: "buffer" });
const rows = XLSX.utils.sheet_to_json(workbook.Sheets[sheet]);
return rows;
};
module.exports = {
read,
};
});
Versions
- Cypress version: 10.4.0
- Preprocessor version:11.4.0
- Node version:16.14.2
Checklist
- [ x] I’ve read the FAQ.
- [ x] I’ve read Instructions for logging issues.
- [x ] I’m not using
cypress-cucumber-preprocessor@4.3.1
(package name has changed and it is no longer the most recent version, see #689).
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
I can’t really see how this ever worked, in any version.
I can chime in and say that this is the only way. At no point has anyone been able to do anything else. You simply can’t run a node module in the browser. You might have been able to make a node module compile with earlier versions of browserify / webpack, but it just wouldn’t behave as you’d expect.