question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow custom cleanup functions in TestScheduler

See original GitHub issue

🚀 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: https://github.com/americanexpress/jest-image-snapshot/issues/59#issuecomment-421222824

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!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
markov00commented, Dec 19, 2019

Hey there any news on this?

0reactions
github-actions[bot]commented, May 1, 2022

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. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Removed snapshots are not cleaned up · Issue #59 - GitHub
Turns out, jest-snapshot exports a cleanup function (code here) that ... Allow custom cleanup functions in TestScheduler facebook/jest#7093.
Read more >
Practical Testing with RxTest - part I - Paramount Tech
We should allow Test Scheduler to consume all relevant events first. And only then we should perform a start operation on it. So...
Read more >
TestScheduler-created ColdObserver not unsubscribing when ...
On your test I see immediate resource clean-up, as I would expect. And with this change your test will now pass because SpyResourceCleanUp...
Read more >
Understanding React's useEffect cleanup function
React's useEffect cleanup function saves applications from unwanted behaviors like memory leaks by cleaning up effects.
Read more >
Asynchronous testing - Documentation - Akka
Asynchronous testing uses a real ActorSystem ActorSystem that allows you to test your Actors in a more realistic environment. The minimal setup consists...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found