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.

Ability to skip rest test cases if one fails

See original GitHub issue

🚀 Feature Proposal

Provide ability to skip rest test cases in a file or describe block if one test fails.

Motivation

For E2E testing, the test cases are usually written to be run sequentially, and a failed test should stop the rest from running.

Example

test('should login', async () => {});

test('should edit profile', async () => {});

test('should render profile', async () => {});

Or with describes:

describe('#1', () => {
  test('should login', async () => {});

  describe('#1.1', () => {
    test('should edit profile', async () => {});

    test('should render profile', async () => {});
  });
});

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:33
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
MrLohcommented, May 1, 2020

I created a PR that implements asynchronously canceling tests as described in #8604. With that in place, one could implement this functionality through easy monkey patching in user land like this:

let prevFailed;
const _describe = global.describe;
global.describe = (...args) => {
  prevFailed = false;
  return _describe(...args);
};
global.test.step = (name, fn, ...args) => {
  test(name, async function(...fnArgs) {
    if (prevFailed) {
      return this.skip();
    }
    try {
      return await fn(...fnArgs);
    } catch (e) {
      prevFailed = true;
      throw e;
    }
  }, ...args);
};
5reactions
MrLohcommented, Sep 3, 2020

#9944 But I doubt it will ever be merged, I haven’t heard back a single word from any contributor.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to skip the rest of tests in the class if one has failed?
I'm able to contain the failure inside the Class (Test Case) with the help of teardown_class() , however I'm looking into how to...
Read more >
WebDriver - All test cases skipped because of one failure
It seems like IE driver or WebDriver triggers some chain reaction, in case one test case fails the rest are skipped. This does...
Read more >
How to skip all remaining tests if initial login test fails?
Looking for a way to mark the initial login as failed and then stop the entire test from running. EDIT: this works to...
Read more >
How to run, ignore or skip Jest tests, suites and files
When debugging or writing units tests with Jest it can be useful to specify a single file or test to run or to...
Read more >
How to skip Test and execute another if one failed...
For example, you can set the Stop on error property of an individual test item to Test Item. In this case, if an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found