question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Reactions:44
  • Comments:48 (7 by maintainers)

github_iconTop GitHub Comments

77reactions
medikoocommented, Oct 23, 2018

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

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)

63reactions
palmerj3commented, Oct 23, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found