如何解决“CypressNpmApi”类型上不存在属性“env”
我在尝试使用 cypress.env.json 文件时收到此打字稿错误。
cypress.env.json
{
"email": "myemail@somewhere.com","password": "Password123"
}
steps.ts
/// <reference types="cypress" />
import Cypress from 'cypress';
Given(/I login to TMDB/,url => {
Cypress.env('email'); // <- error here
});
“CypressNpmApi”类型上不存在属性“env”
https://github.com/inspiraller/next-cypress-cucumber-boilerplate
解决方法
归功于 - https://github.com/TheBrainFamily/cypress-cucumber-preprocessor/issues/565#event-4746536875
通过简单地删除我的 Cypress 导入来解决。由于这应该通过 tsconfig.json 中的打字稿自动可用
更新代码
/// <reference types="cypress" />
// import Cypress from 'cypress'; <- remove this line
Given(/I login to TMDB/,url => {
Cypress.env('email'); // <- Now correctly works
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。