You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be really useful if the beforeEach and afterEach hooks had access to the input being feed to the predicate for every check. So the hooks would take two parameters instead of one... the previous hook and the values that will be passed to the predicate.
Motivation
This is related to mocking using Sinon as I have multiple tests that need to use the values generated by the arbitraries to create new mocks for each iteration of a check. This feature would allow me to effectively replace Mocha's beforeEach and afterEach hooks which are usually used for this purpose.
This is a fake example but I hope it illustrates what I'm wanting. Imagine we have a dependency "someDep" which the code I'm testing imports. For each iteration I want a function exported by "someDep" (call it: "depFunc") to return something based on the current tests data produced by my arbitraries.
The way I have to do things now I end up duplicating the code that sets up and tears down the mock in every test.. which is tedious and clutters the test. If I had access to the test data in the beforeEach and afterEach then it greatly simplifies the test code and is so much cleaner and easier to understand.
The text was updated successfully, but these errors were encountered:
Good idea, I need to check how it can fit with my on-going stream on v4 of fast-check. But as I'm currently preparing a new major, probably worth I check that one before putting the major live 🤔
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
🚀 Feature Request
It would be really useful if the
beforeEach
andafterEach
hooks had access to the input being feed to the predicate for every check. So the hooks would take two parameters instead of one... the previous hook and the values that will be passed to the predicate.Motivation
This is related to mocking using Sinon as I have multiple tests that need to use the values generated by the arbitraries to create new mocks for each iteration of a check. This feature would allow me to effectively replace Mocha's
beforeEach
andafterEach
hooks which are usually used for this purpose.Example
I'm using this handy function to mock entire modules which are dependencies of my code under test: https://spin.atomicobject.com/2018/06/13/mock-typescript-modules-sinon/
This is a fake example but I hope it illustrates what I'm wanting. Imagine we have a dependency "someDep" which the code I'm testing imports. For each iteration I want a function exported by "someDep" (call it: "depFunc") to return something based on the current tests data produced by my arbitraries.
Let say
myTestFunc
looks like this:Right now I have to do something like this in my test:
What I'd rather do is something like this:
The way I have to do things now I end up duplicating the code that sets up and tears down the mock in every test.. which is tedious and clutters the test. If I had access to the test data in the
beforeEach
andafterEach
then it greatly simplifies the test code and is so much cleaner and easier to understand.The text was updated successfully, but these errors were encountered: