cypress error: " Cannot read property 'fs.existsSync' of undefined"

Viewed 746

I recently picked up the cypress config & tests for our project after the original developer left. I'm haivng problems getting the existing tests to run: The tests all throw this error when running from the command line:

TypeError: The following error originated from your test code, not from Cypress.
. > fs.existsSync is not a function

When I start up the GUI, it throws the same error, like so:

GUI failure mode

I found nothing in the issues nor on the web, except to see that fs.existsSync is deprecated.

When I checked the cypress.io's gitter site, they recommended that I trap errors with the following code which I added to my support/index.js file:

Cypress.on('uncaught:exception', (err, runnable) => {
    // returning false here prevents Cypress from
    // failing the test
    return false
})

And now cypress crashes with the following before even starting the GUI:

crash before displaying GUI

This is a basic test:

basic test case using defined commands

Which use a series of defined commands like so:

defined command sample

The tests were running when originally created; I have upgraded to cypress 4.8.0 with no luck.

Has anyone seen anything like this? I'd sure like to get these tests running again. thanks

1 Answers

You are seeing the error due to this: import 'Cypress';

enter image description here

You need not explicitly import Cypress.

I too can reproduce the same error when I added the 'import' statement.

enter image description here

Related