Is relying on @testing-library's get*
methods to throw and fail a test an anti-pattern?
#2198
-
I am working on a PR to add However, as I've been modifying the tests to resolve the ESLint warnings, I've started to wonder whether relying on the
However, I have the following concerns with this approach that make me think it might be an anti-pattern:
@obulat @dhruvkb since y'all work in the frontend the most. Additionally, I'd like to ping @AetherUnbound as someone who is reviewing frontend PRs. I have especially in mind the fact that we should make it as easy as possible to not write incorrect unit tests because we can't rely on expertise and nuanced knowledge of the libraries we use. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
In addition to switching to not use |
Beta Was this translation helpful? Give feedback.
-
I agree with your reasoning about the |
Beta Was this translation helpful? Give feedback.
-
Olga and Zack have agreed that this isn't a good approach. I've created six issues to update the modules that use non-explicit assertions based on Each are |
Beta Was this translation helpful? Give feedback.
Olga and Zack have agreed that this isn't a good approach. I've created six issues to update the modules that use non-explicit assertions based on
get*
. They are contained in this milestone: https://github.com/WordPress/openverse/milestone/13Each are
medium
priority based on the potential for misuse/misunderstanding. The milestone includes a note for whyv-tabs
is excluded despite the fact that it extends the assertion function names (it does so appropriately). Thev-popover.spec.js
issue includes a caveat along the same lines.