You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
馃殌 Feature Proposal
Use
describe's
first argument (i.e.name
) to differentiate test cases with the samename
.Motivation
The point of using
describe
andit
("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.
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:
Pitch
The text was updated successfully, but these errors were encountered: