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

Venkata
  • 656
  • 6
  • 17

2 Answers2

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
    }
}
Toli
  • 5,547
  • 8
  • 36
  • 56
2
/* global cy */

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

haxora
  • 81
  • 6