-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
added thrown error for duplicate testcases in describe instance #4302
base: main
Are you sure you want to change the base?
added thrown error for duplicate testcases in describe instance #4302
Conversation
testcases have a 1 to 1 relation with functions so each test name should map to one function only, can't map to multiple functions in the same describeInstance
@badra022 Thanks for this PR. Could you please sign the CLA as well? |
just signed it, thanks @garg3133 |
Status
|
This is potentially a breaking change because while it does run fine in the serial mode -- stops the test run with an error that is easily actionable, it just altogether skips the test suite during a parallel run without reporting any error in the HTML report. This is not ideal (and breaking) because the tests which were running earlier no longer run and it's not very straightforward for the user to know that a few tests stopped running. Would need to spend some more time on this to figure out how the error can be better reported during a parallel run. |
lib/testsuite/context.js
Outdated
const {Logger} = Utils; | ||
|
||
const err = new Error( | ||
'An error occurred while loading the testsuite:\n' + | ||
`A testcase with name "${testName}" already exists. Testcases must have unique names inside the test suite, ` + | ||
'otherwise testcases with duplicate names might not run at all.\n\n' + | ||
'This testsuite has been disabled, please fix the error to run it properly.' | ||
); | ||
Logger.error(err); | ||
|
||
this.setAttribute('@disabled', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@badra022 Does this look like an acceptable solution? |
Description
duplicate testcases inside describe instance that have same testName runs only the second test function for each time, this behavior should not be allowed so the user should have a thrown error explaining this to make test names inside the describe suite unique
Proof of work
here it shows the error when you write two tests with the same name inside the describe test suite
Thanks in advance for your contribution. Please follow the below steps in submitting a pull request, as it will help us with reviewing it quicker.
examples/tests
directory of the project) and running them.ecosia.js
andduckDuckGo.js
are good examples to work with.features/my-new-feature
orissue/123-my-bugfix
);