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
Warn about assertion name collisions between 2 libs extending jest #9678
Comments
Related to (or duplicate of) #6243 |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
馃殌 Feature Proposal
Warn users when they have two matchers with colliding names. (and one is being overwritten silently)
Motivation
At the moment there is the case with
jest-extended
andtesting-lib/dom
.Both libraries have an assertion called
toBeEmpty
.In jest-extended, it checks for emptiness in data, in testing-lib/dom, it checks for emptiness in the DOM.
https://github.com/testing-library/jest-dom#tobeempty
https://github.com/jest-community/jest-extended#tobeempty
The situation is that as developers add both libraries in the project, one of the
toBeEmpty
will be silently overwritten, and when they start using them in their unit tests, and the test does not pass, regardless of being empty, they will not know what the problem is.As there is no mechanism to decide which assertion names are already taken by libraries extending
jest
, an option to handle this, would be to warn users, as they install or run their tests, with 2 assertion names colliding, that the collision is happening, so that they can rename one of both in their projectsIn my case I did by doing this as a very quick and dirty fix:
Idea
I dont know the codebase in Jest to give more specific ideas, what I am thinking is, as they run their tests, to show a warning telling them that these 2 libs are using the same name for a matcher, and give them a link to find a solution to rename one in their configs.
For reference
I reported this in the author's libs, before deciding how to address this, would be helpful to read your thoughts on it.
testing-library/jest-dom#216
The text was updated successfully, but these errors were encountered: