-
-
Notifications
You must be signed in to change notification settings - Fork 175
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for beforeEach/afterEach in fast-check/jest #3942
Comments
Definitely something worth adding. It would require te have a way to either hook into the beforeEach defined for Jest or expose one via fast-check and fill the one of Jest with it. |
+1 for this, I'm trying to use with |
For now, you can use https://fast-check.dev/docs/configuration/global-settings/#shared-settings with beforeEach or beforeEachAsync |
Hey - any updates on this? If needed, I can try implementing this and open a pull request if I manage to... |
@ej-shafran I have not worked on this issue recently. You can give it a try if you want |
馃殌 Feature Request
I am having issues using sinon to mock things when running fast-check with jest, one cannot re-mock something with sinon that has already been mocked.
So after each test the mocks have to be restored, this can be done via either the
afterEach
hook for a specific property test or with the global hooks when not using fast-check/jest.But when using fast-check/jest these hooks are not available (at least not what i could find) and the global hooks don't seem to be applied. The beforeEach/afterEach hooks provided by jest does not work as they are not executed on every single check which they need to be.
This also applies for the
cleanup
method from@testing-library/react
which will also need to be executed after every test.Motivation
This would be very appreciated as the omission of this feature from fast-check/jest makes testing several things a lot more complicated and annoying requiring either manually calling the cleanup stuff or constructing workarounds.
Example
Here is a bit of a contrived example.
This will fail with:
The text was updated successfully, but these errors were encountered: