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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Allow cases in different suites in the same test file to have the same name. #14997

Open
geoidesic opened this issue Apr 2, 2024 · 1 comment

Comments

@geoidesic
Copy link

geoidesic commented Apr 2, 2024

馃殌 Feature Proposal

Use describe's first argument (i.e. name) to differentiate test cases with the same name.

Motivation

The point of using describe and it ("should blah blah") is to make the tests more easily human readable. One problem with the implementation is that having test multiple cases with the same names in two different suites (in the same file) will cause the latter case results to override the former's.

E.g.

describe("MyFunction", () => {
  it("should return true for valid input", () => {
    // Test implementation
  });

  it("should return false for invalid input", () => {
    // Test implementation
  });
});
describe("MyOtherFunction", () => {
  it("should return true for valid input", () => {
    // Test implementation: overrides MyFunction test
  });

  it("should return false for invalid input", () => {
    // Test implementation: overrides MyFunction test
  });
});

This makes it unwieldy because you have to ensure that every case has a unique identifier. It also shouldn't be necessary because the cases are already differentiated by being in a different suite. It should be relatively straight forward to adjust the implementation to concatatenate the suite and case names together for your key store.

Example

Instead of having to write it like this:

describe("MyFunction", () => {
  it("should return true for valid input in MyFunction", () => {
    // Test implementation
  });

  it("should return false for invalid input in MyFunction", () => {
    // Test implementation
  });
});

describe("MyOtherFunction", () => {
  it("should return true for valid input in MyOtherFunction", () => {
    // Test implementation
  });

  it("should return false for invalid input in MyOtherFunction", () => {
    // Test implementation
  });
});

Pitch

  • allows my test case names to be written it more concisely
  • better readability (less cognitive load)
  • makes it easier to read in a UI app like Majestic, which already indents cases by suite, so all the additional text, currently necessary, isn't welcome
  • should be easy to implement without side-effects on the existing system
Copy link

github-actions bot commented May 2, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label May 2, 2024
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