1. ///<reference types="cypress" />
    2. const { should } = require("chai");
    3. describe("测试动态忽略测试用例", function(){
    4. context("test_01", function(){
    5. it("动态跳过用例", function(){
    6. if (Cypress.env('flag')==1){
    7. cy.log("测试通过");
    8. expect("foo").to.be.a('string');
    9. expect([1, 2, 3]).to.have.members([2, 1, 3]);
    10. }
    11. else{
    12. console.log("测试失败");
    13. cy.log("测试失败") //跳过时,cy相关的命令不会被执行
    14. this.skip();
    15. }
    16. });
    17. it("测试1=1", function(){
    18. expect(1).to.equal(1);
    19. });
    20. });
    21. });

    执行命令 yarn cypress:open —env flag=1