Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where does cy variable coming from in cypress

Tags:

cypress

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

like image 428
Venkata Avatar asked Aug 28 '18 16:08

Venkata


1 Answers

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
    }
}
like image 164
Toli Avatar answered Sep 24 '22 11:09

Toli