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
I made tests a bit too verbose in #11616.
Might be a good time to revisit how we write them now.
There's a few separate issues:
Asserting on warning messages is too verbose. Need a DEV block, call spyOnDev, normalize stack, etc. Ideally I wish there was a higher level helper that lets us "push" expected warning assertions and validate them as they happen. It should handle component stacks automatically without having to copy-paste the normalization helper everywhere.
In some cases I added actual duplication in Run Jest in production mode #11616, in particular for cases that throw in development but don't throw in production. Maybe need a toThrowInDev()? Although on the other hand this pattern needs to be highly visible so maybe extracting common code in a closure is good enough.
The text was updated successfully, but these errors were encountered:
for the most common console.error case. If pattern is a string, it expects a single warning. If it is an array, it expects multiple warnings. All patterns are normalized so it's easy to match the component stack traces.
The nice thing about it is it clearly scopes which code is supposed to warn. The downside of this is that it's harder to assert on things that both throw and warn because you'd have to wrap the code twice (or else add a new helper).
Another thing to consider. We currently globally mock ReactFiberErrorLogger because it is too noisy. We could remove that global mock but then every test that throws inside React call stack would also log a warning (which it does for consumers in open source). Maybe we could solve this with an extra matcher. Or make it configurable somehow.
I made tests a bit too verbose in #11616.
Might be a good time to revisit how we write them now.
There's a few separate issues:
Asserting on warning messages is too verbose. Need a DEV block, call
spyOnDev
, normalize stack, etc. Ideally I wish there was a higher level helper that lets us "push" expected warning assertions and validate them as they happen. It should handle component stacks automatically without having to copy-paste the normalization helper everywhere.In some cases I added actual duplication in Run Jest in production mode #11616, in particular for cases that throw in development but don't throw in production. Maybe need a
toThrowInDev()
? Although on the other hand this pattern needs to be highly visible so maybe extracting common code in a closure is good enough.The text was updated successfully, but these errors were encountered: