How to programmatically skip a test in mocha?

前端 未结 14 1172
失恋的感觉
失恋的感觉 2020-12-07 17:31

I have a code where certain tests will always fail in CI environment. I would like to disable them based on an environment condition.

How to programmatically skip a

14条回答
  •  广开言路
    2020-12-07 17:39

    Use Mocha's skip() function

    It can be used to either statically to disable a test or entire suite, or dynamically skip it at runtime.

    Here's an example runtime usage:

    it('should only test in the correct environment', function() {
      if (/* check test environment */) {
        // make assertions
      } else {
        this.skip();
      }
    });
    

提交回复
热议问题