我试图只运行一组测试,如果版本是某个数字或更高的cypress,但我似乎不能让它正常工作。下面的代码有点抽象,但显示了整体结构:
if (version < 8203) {
context('Skipping Tests', () => {
it('Feature Not Available', () => {
cy.task('log', "Skipping test. Feature not available in this version");
});
});
else {
context('Testing Feature', () => {
it('Test 1', () => {
});
it('Test 2', () => {
});
it('Test 3', () => {
});
});
}我不确定这是否是正确的方式,我已经尝试了几种不同的方法来构造它,包括将if语句放在上下文中,但看起来cypress忽略了if语句,或者只是移动到最后一个上下文,它就会起作用。
发布于 2020-12-01 12:07:18
您提到了用于获取version中的值的代码。
let version;
getVersion((setVersion) => {
version = parseInt(setVersion.replace(/[v.]/g, ''));
console.log(version); //8203
});
if (version < 8203) { ??? is this where you test ???如果上面的模式是您的测试看起来的样子,那么在评估if()之前,我会说getVersion()回调还没有完成。
这种结构能改善事情吗?
let version;
getVersion((setVersion) => {
version = parseInt(setVersion.replace(/[v.]/g, ''));
console.log(version); //8203
if (version < 8203) {
...
}
else {
context('Testing Feature', () => {
it('Test 1', () => {
...
});
}
});https://stackoverflow.com/questions/65082034
复制相似问题