Skip to content
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

feat: make detailed errors opt-in #15016

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

G-Rath
Copy link
Contributor

@G-Rath G-Rath commented Apr 7, 2024

Summary

This aims to reduce the occurence of #10577 without solving it entirely by making what I believe to be the main source (#9496) opt-in (which we can do because this is being landed in a new major).

More specifically, it changes jest-circus to not include "detailed" errors by default unless the --detailed-errors-in-results flag is passed; including these causes circular reference errors because they're actually a JavaScript reference to whatever error that got thrown in a test - on a good day, that'll be a Jest assertion error as a result of an expect failure (which don't have any circular references), but the error can be literally anything including those thrown by ESLint in its RuleTester (which includes the AST tree which has circular references) and arbitrary objects that can include functions (which cannot be serialized).

As far as I know these detailed errors are actually only being used by JetBrains IDEs and it should be trivial for those that want to actually use them to provide the new flag to have their details included, and being able to account for the tradeoffs (namely "you might get circular reference errors").

Alternatively this could be landed with the inverse default, which'd still be useful by allowing users to explicitly have those details left out so they can see what the actual error they're getting is with the understanding that their tooling might not be as effective due to the detailed errors being missing.

Test plan

umm write some tests, probably

Copy link

netlify bot commented Apr 7, 2024

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 45ad8c0
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/66353b3fdfb9d200081aa410
😎 Deploy Preview https://deploy-preview-15016--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@G-Rath
Copy link
Contributor Author

G-Rath commented Apr 7, 2024

@SimenB could you let me know if this is something you'd be ok to land in any form? and if so let me know how far you'd like to go i.e. do we still care about Jasmine, and do we need to have an extensive set of tests that tries to cover behaviour both with and without the flag and with and without circular references, etc?

@G-Rath
Copy link
Contributor Author

G-Rath commented Apr 7, 2024

oh and I tested this worked with eslint-plugin-jest - currently if you do yarn run test --watch when implementing a feature it errors, whereas with this it doesn't.

@G-Rath
Copy link
Contributor Author

G-Rath commented Apr 7, 2024

The "error with cause" snapshot change looks odd to me - not sure why this change would mean it no longer includes an entire error...?

@G-Rath G-Rath force-pushed the allow-disabling-failure-details branch from 3c6e307 to 01c50ef Compare April 7, 2024 05:21
@G-Rath G-Rath marked this pull request as ready for review April 7, 2024 05:30
@G-Rath
Copy link
Contributor Author

G-Rath commented Apr 7, 2024

Ok so it looks like in #13966 Jest might have started using failureDetails (which is the reporter side of errorsDetailed) internally (I can't test for sure as I've not been able to remember how to run specific e2e tests) - confirmed, if I change the test to pass in --detailed-errors-in-results it passes

What's interesting though is that PR is titled as adding support for causes to Jasmine whereas #13965 (which doesn't use failureDetails) was landed first adding it to snapshots - does that mean maybe circus doesn't need it...?

Either way it's an extra bit of annoyance but I still think having this flag is worth it


Ok I think what this is is that #13965 landed support for causes to jest-snapshot in the general sense, and then #13965 landed support for the runners actually passing the error details along

@G-Rath G-Rath force-pushed the allow-disabling-failure-details branch from cd09737 to d7ab1b1 Compare April 17, 2024 18:56
@G-Rath

This comment was marked as resolved.

@G-Rath G-Rath force-pushed the allow-disabling-failure-details branch from d7ab1b1 to d7c0f27 Compare April 24, 2024 22:11
@G-Rath G-Rath force-pushed the allow-disabling-failure-details branch 3 times, most recently from 35807d6 to 08550d7 Compare April 26, 2024 19:04
@G-Rath G-Rath force-pushed the allow-disabling-failure-details branch from 08550d7 to 45ad8c0 Compare May 3, 2024 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant