Lar*_*ger 3 javascript testing intellisense typescript cypress
我有这个cypress.json配置文件:
{
"env": {
"example": "Hello World!"
}
}
Run Code Online (Sandbox Code Playgroud)
在我的测试中:
Cypress.env("example")
Run Code Online (Sandbox Code Playgroud)
我可以向环境系统添加任何类型的定义吗?(与 Typescript 或 eslint 一起使用)我很想在这里使用智能感知。
来自 cypress.d.ts
interface Cypress {
/**
* Returns specific environment variable or undefined
* @see https://on.cypress.io/env
* @example
* // cypress.json
* { "env": { "foo": "bar" } }
* Cypress.env("foo") // => bar
*/
env(key: string): any
}
Run Code Online (Sandbox Code Playgroud)
所以你可以用它来扩展它
declare namespace Cypress {
interface Cypress {
env(key: "example"): string
}
}
Run Code Online (Sandbox Code Playgroud)
这给出了智能感知(method) Cypress.Cypress.env(key: "example"): string (+6 overloads)
| 归档时间: |
|
| 查看次数: |
1150 次 |
| 最近记录: |