Javascript 基于请求响应跳过cypress测试

Javascript 基于请求响应跳过cypress测试,javascript,automation,automated-tests,cypress,Javascript,Automation,Automated Tests,Cypress,我需要一种基于IF/ELSE条件评估的方法来跳过Cypress中的测试块。下面是我的代码 it("Website testing",function(){ cy.request({ method: 'GET', url: "http://127.0.0.1:5000/isIPv6", timeout:300000 }).then(network_resu

我需要一种基于IF/ELSE条件评估的方法来跳过Cypress中的测试块。下面是我的代码

it("Website testing",function(){
        cy.request({
            method: 'GET',
            url: "http://127.0.0.1:5000/isIPv6",
            timeout:300000
        }).then(network_result => {
            cy.log(network_result.body)
            if(network_result.body.isIPv6 == false)
            {
               statements
            }
            else
            {
                cy.log("IPv6 device, stopping the test")
                this.skip()
             }
         })
})
上面的代码段不起作用,因为
this.skip()
是一个同步语句,而cypress为它提供了错误

我也尝试过
it.skip()
throw()
,但在这种情况下没有用。
我需要一种方法,在执行控制转到else块时,我可以跳过测试执行/块,并将测试发送到跳过/挂起状态。

我看到您有
it(title,function(){…}
模式,允许访问和修改
,但您可能还需要将其应用于
中的回调。然后()

it(“网站测试”,功能(){
赛义德请求({
...
}).then(功能(网络结果){
...
否则{
...
this.skip()
}
})
})

刚刚注意到
skip()
it()
中,但是您应该在
it()
开始之前跳过测试,所以可能

beforeach(函数(){
赛义德请求({
...
}).then(功能(网络结果){
...
否则{
...
this.skip()
}
})
})
它('如果beforeach调用“this.skip()”,()=>{
...
})

我看到您有
it(title,function(){…}
模式,它允许访问和修改
,但您可能还需要将其应用于
中的回调。然后()

it(“网站测试”,功能(){
赛义德请求({
...
}).then(功能(网络结果){
...
否则{
...
this.skip()
}
})
})

刚刚注意到
skip()
it()
中,但是您应该在
it()
开始之前跳过测试,所以可能

beforeach(函数(){
赛义德请求({
...
}).then(功能(网络结果){
...
否则{
...
this.skip()
}
})
})
它('如果beforeach调用“this.skip()”,()=>{
...
})
您可以检查此线程-您可以检查此线程-