After adding new libraries it says:
Uncaught TypeError: Cannot read property 'prototype' of undefined
Use external library functions properly
npm install Cypress --save-dev
npm install excel --save-dev
npm install babel-cli --save-dev
npm install babel-preset-env --save-dev
npm install mocha --save-dev;
in test file in integration insert code below:
var parseExcel = require('excel/commonjs/excelParser').default;
Mac
electron 59
I was able to reproduce this.
@kutlaykural Cypress is running in the browser and so does not have native Node.js access. The above error seems to be caused by fs$ReadStream in the below being undefined:
var fs$ReadStream = fs.ReadStream
ReadStream.prototype = Object.create(fs$ReadStream.prototype) // point of failure
ReadStream.prototype.open = ReadStream$open
I suggest looking into cy.task:
https://docs.cypress.io/api/commands/task.html#
As well as cy.exec:
https://docs.cypress.io/api/commands/exec.html#
These commands can help you execute Nodejs code at the OS level and then return the results to the browser.
@kutlaykural, @EirikBirkeland is correct - you cannot require node specific libraries into browser code, but you can use cy.exec, cy.request, or the new and best cy.task for interopt with the background node process. This will enable you to do anything you'd like.
Most helpful comment
@kutlaykural, @EirikBirkeland is correct - you cannot require node specific libraries into browser code, but you can use
cy.exec,cy.request, or the new and bestcy.taskfor interopt with the backgroundnodeprocess. This will enable you to do anything you'd like.