Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Add expect().toBeInconclusive() and provide that count along with Pass, Fail #15413

Open
BlitzkriegSoftware opened this issue Dec 7, 2024 · 0 comments

Comments

@BlitzkriegSoftware
Copy link

BlitzkriegSoftware commented Dec 7, 2024

🚀 Feature Proposal

Other testing frameworks have an inconclusive() result type which is useful in the scenarios listed in the next section.

Feature Details:

  • Add to expect method .toBeInconclusive(reason) (where reason is a string containing why) which should be emitted as part of testing.

    • My .02 is that reason should be a required field e.g. not Falsy or nil
    • This method would only be triggered if expect(expression) evaluates to False e.g., test is not run-able
  • In test summaries, include the count of inconclusive along with Pass, Fail

  • In theory inconclusive tests would not contribute to code coverage, although, that is an area to consider

Motivation

Inconclusive scenarios:

  1. Partially completed tests created as part of TDD (etc.)
  2. Unable to meet test preconditions due to hardware/environment issues (test might pass otherwise)

Example

// UC 1:
expect(false).toBeInconclusive('Test not finished');

// UC 2: Test is un-run-able
//    Fetch the number of CPU Cores
const numCores = require('os').cpus().length ?? 0;
//    If evaluation is false, the test is inconclusive
expect(numCores < 2).toBeInconclusive('At least two CPU cores are required');

Pitch

  1. It brings jest compatible with other platforms
  2. It provides useful functionality for development teams
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant