Skip to main content
Cypress应用

Cypress.testingType

Cypress.testingType 返回当前测试类型,该类型由您在 Cypress Launchpad 中的选择决定。Cypress.testingType 会返回 e2e 表示 端到端测试component 表示 组件测试

语法

Cypress.testingType // 返回 'e2e' 或 'component'

示例

测试类型

it('正在运行组件测试模式', () => {
expect(Cypress.testingType).to.equal('component')
})

条件判断

it('执行不同的操作', () => {
if (Cypress.testingType === 'e2e') {
cy.exec('something')
} else {
cy.exec('something else')
}
})

历史版本

版本变更
7.0.0新增 Cypress.testingType 功能