Skip to content

Fast fail feature for the node:test context #42990

Closed
@null8626

Description

@null8626

What is the problem this feature will solve?

A test's progress can sometimes be crucial for the next one, if one of them fails, say like this:

let module;
let instance;

test("importing module", async () => {
  module = await import("...");
});

test("using module feature 1", () => {
  instance = new module.SomeExportedClass("arg1", { option: true });
});

test("request to API", async () => {
  await instance.apiEndpoint({ ... });
});

While yes, if the library has checks, this would be pointless, but it would be better to have an option for the the rest of the tests to fail if one had failed.

What is the feature you are proposing to solve the problem?

Something like this:

test("test for myModule", { fastFail: true }, (t) => {
  t("test that fails", () => {
    // This should make the next tests to fail as well.
    assert(false);
  });

  t("test that will never succeed", () => {
    console.log("This won't log to the console.");
  });
});

What alternatives have you considered?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions