-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Allow custom cleanup functions in TestScheduler #7093
Comments
Hey, bumping this -- any thoughts? |
Hey @piratefsh, it makes sense to me on the surface - how do you recommend we expose hooking into it? |
Hey @rickhanlonii, my initial thought is that custom matchers can export a For the cleanup to work for snapshot-style matchers,
If it cannot find a corresponding test for a snapshot file, it assumes that the snapshot file is no longer valid. This assumes that it's a one-to-one mapping between test and snapshot file though, so there is that limitation. Also, when running a subset of tests, the cleanup function only affect the related files. I can imagine it to get confusing if I ran a single test suite and it ends up cleaning up old snapshot from unrelated tests. What do you think? Happy to think this through further and to hear your thoughts. |
How does that play with #6143? |
@SimenB Oh cool, didn't know about that PR! It should work with custom resolvers. Since the cleanup function will be implemented by the matcher itself, it should have the access to use its resolver. I don't forsee any conflict there. Did you have any thoughts or concerns? I am also open to working on this! |
A PR with the changes you need would be awesome! No guarantee we'll merge, but often easier to discuss when there's some concrete code to look at 🙂 |
Hey there any news on this? |
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
Allow custom cleanup functions to be run by
TestScheduler
. Currently,TestScheduler
only runs cleanup for jest snapshots (code here).I would like a way to specify a custom cleanup function, or to have an expectation that a custom matcher can export it's own cleanup function.
Motivation
Custom matchers generate snapshots that can be obsolete once the corresponding test files have been removed. See related
jest-image-snapshot
issue here: americanexpress/jest-image-snapshot#59 (comment)When working with a custom matcher e.g.
jest-image-snapshot
, there doesn't seem to be a way to run a cleanup function after all tests have finished running. Custom matchers may also save snapshot files with their own naming format, which may not correspond to jest-snapshot naming conventions,Example
See motivation above ^
Pitch
A cleanup should run after all tests have been completed, which is known to TestScheduler. As far as I can see, that is the best place that this can happen -- happy to hear out and discuss alternative implementations!
The text was updated successfully, but these errors were encountered: