Cypress.isCy
Cypress.isCy()
用于检查变量是否为 cy
的有效实例或可链式对象。
当使用 Node Events 为 Cypress 编写插件时,若需要判断某个值是否为有效的 Cypress 可链式对象,此工具函数会非常有用。
语法
Cypress.isCy(obj)
参数
obj (Object)
待测试的对象。
示例
Cypress.isCy(cy) // true
const chainer = cy.wrap().then(() => {
Cypress.isCy(chainer) // true
})
Cypress.isCy(undefined) // false
Cypress.isCy(() => {}) // false