12

I am have installed ESlint in out test project and it started to show me few errors that i need to resolve

one of the error is in cy.request('someURL');

The error is cy is undefined

so I have added a import statement on top of file like this

import { cy } from 'cypress';

After adding this statement none of the requests are going through I am getting this error when i try executing the tests.

Error

Tests are executing perfects once i remove the import statement

where am i going wrong

2 Answers 2

16

cy is a global variable. Much like location. So really it is window.cy. You can add it to the globals in Eslint. Don't import cy from cypress.

{
    "globals": {
        "cy": true
    }
}
2
/* global cy */

import above in your test file (cypress test file ex: cypress/integration/login.js

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.