Snapshot testing panic message #571
IzawGithub
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, thank you for the crate! It makes snapshot testing a breeze and is very useful.
I have searched the docs but I'm not finding anything about how to do snapshot testing for panic.
Basically, I've got some fatal errors that panics my entire program. They do some fancy formatting and localization before, so I want to do snapshot on them.
Right now I've got something like this:
Works great when there's a single test. Unfortunately,
std::panic::HOOK
is not thread local, so if I've got 2 test like this, then there is a race condition.I could implement a mutex, or using a crate like thread_local_panic_hook, but the ergonomics would be better if insta could handle panic message directly.
Would something like this be feasible to implement?
This would mean the above code could be simplified to something like this:
Keep in mind I have no experience with procedural macro so I have no idea if it's even possible.
Beta Was this translation helpful? Give feedback.
All reactions