Skip to content

Expect test to fail (xfail style) #10030

@willstott101

Description

@willstott101

🚀 Feature Proposal

The ability to mark a test as expected to fail probably with the following syntax:

describe('Test isCool function works', {
  test('jeff is the best', () => {
    expect(isCool("jeff")).toBe(true);
  });

  test.xfail("for some reason I'm not coming out as cool...", () => {
    expect(isCool("will")).toBe(true);
  });
});

And suggested output:

Test Suites: 1 failed, 5 passed 6 total
Tests:       1 failed, 16 passed, 2 expected failures, 2 unexpected passes, 21 total
Snapshots:   0 total
Time:        2.627s, estimated 4s
Ran all test suites.

Motivation

Many testing frameworks allow you to specify a test as a expected failure. This can be very useful for long-term TDD and for testing known-bugs are still bugs without implying that it's intended behaviour.

Example

In the above output, an engineer should be surprised (and pleased) by the 2 unexpected passes and change those tests to test from test.xfail if their commit caused the fixes. Otherwise they can leave as is for an engineer who understands those tests to mark as resolved.

Pitch

I feel this is a core feature as it's a fundamentally new result status for tests.

See some great comments from an older issue #8317

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions