cy变量来自哪里? [英] where does cy variable coming from in cypress

查看:64
本文介绍了cy变量来自哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在测试项目中安装了ESlint,它开始向我显示一些我需要解决的错误

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

其中一个错误是cy.request( 'someURL');

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

错误是cy未定义

所以我在顶部添加了import语句像这样的文件

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.

删除导入后,测试将完美执行语句

Tests are executing perfects once i remove the import statement

我要去哪里了

推荐答案

cy 是全局变量。很像位置。所以确实是 window.cy 。您可以将其添加到Eslint中的全局变量。请勿从赛普拉斯导入 cy

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
    }
}

这篇关于cy变量来自哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆