Allow to skip tests programmatically
See original GitHub issue🚀 Feature Proposal
Mocha supports skipping tests programmatically (in both before
and it
) as:
describe("Some test" () => {
it("Should skip", function () {
if (true) {
this.skip(); // test marked as skipped, no further part run
}
notInvoked();
});
}):
Motivation
It’s very useful for cases where during tests setup we find out whether test can be pursued or not e.g. we need some external data, but due to some unavailability we can’t so we decide to skip tests.
Is this somewhere on a roadmap?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:44
- Comments:48 (7 by maintainers)
Top Results From Across the Web
How to programmatically skip a test in mocha? - Stack Overflow
You can skip tests by placing an x in front of the describe or it block, or placing a .skip after it. xit('should...
Read more >How to run, ignore or skip Jest tests, suites and files
This post goes how to skip and exclude a single test, a whole Jest test suite and a whole Jest test file using...
Read more >Skipping or disabling tests | Developer Guide - Nightwatch.js
Disabling/skipping individual testcases is supported only when using BDD Describes interface. To skip a testcase, simply mark it as such, using one of:...
Read more >How to ignore/skip or run only one test with Jest
In the below group of tests, I have three tests. test 1 and test 3 will run, but because test 2 uses test.skip...
Read more >Programmatically skip / ignore tests in MSTest v2
<summary> · An extension to the [Ignore] attribute. · skip tests, allow a [TestClass] or [TestMethod] to specify a method to run. ·...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
It serves integration tests. Where tests depend on some external factors, and unavailability of some external resource, shouldn’t indicate a problem with a project (reported with fail) but fact that test cannot be pursued (hence skipped)
This seems like a bad idea to me. Currently you can do it.skip() to explicitly skip a particular test and it’s not even executed.
Skipping programmatically, and only running a portion of your test suite as a result, doesn’t seem like it’s serving the purpose of tests. A test failure at that point would be beneficial so the problem(s) could be fixed. And if they can’t be fixed then marking a test as skipped explicitly like I’ve showed above is an appropriate reaction.