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
Is your feature request related to a problem? Please describe.
Snapshot testing the results of code is quite useful and is the purpose of Snapshooter but I'm interested to propose data input shapshotting as a feature request.
The idea is to re-use the snapshot workflow but for data inputs for tests.
For example, instead of writing/generating test data for a test case you could fetch it from somewhere and have Snapshooter generate a snapshot that can be used for future test executions.
A motivating use-case I have is to test some code that processes data coming out of a big database query.
Creating a mock data set is possible but in our case we already have a big anonymous dataset that our local development + testing environments use and so our unit-tests could leverage this.
Describe the solution you'd like
Here's some pseudocode that describes a possible solution.
When the test is first run the GetData() method would be called to create the input snapshot, saved under the __snapshots__ folder and the result snapshot created as normal.
During future test case executions the Snapshot.Create(...) method would re-use the input snapshot instead of calling GetData().
If a developer wants to update the input snapshot they'd just delete it from the __snapshots__ folder so that it can be re-created.
I think the concepts all work quite nicely together; the test helps us confirm that for the same input (snapshot) we get the same result (snapshot) given some processing logic (unit under test).
Given input and output snapshots might be used in the same test I think input snapshots could have a default filename extension of .input.snap so that they don't conflict with the current snapshot file name(s)
I'm open to contributing a PR as well!
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Snapshot testing the results of code is quite useful and is the purpose of Snapshooter but I'm interested to propose data input shapshotting as a feature request.
The idea is to re-use the snapshot workflow but for data inputs for tests.
For example, instead of writing/generating test data for a test case you could fetch it from somewhere and have Snapshooter generate a snapshot that can be used for future test executions.
A motivating use-case I have is to test some code that processes data coming out of a big database query.
Creating a mock data set is possible but in our case we already have a big anonymous dataset that our local development + testing environments use and so our unit-tests could leverage this.
Describe the solution you'd like
Here's some pseudocode that describes a possible solution.
When the test is first run the
GetData()
method would be called to create the input snapshot, saved under the__snapshots__
folder and the result snapshot created as normal.During future test case executions the
Snapshot.Create(...)
method would re-use the input snapshot instead of callingGetData()
.If a developer wants to update the input snapshot they'd just delete it from the
__snapshots__
folder so that it can be re-created.I think the concepts all work quite nicely together; the test helps us confirm that for the same input (snapshot) we get the same result (snapshot) given some processing logic (unit under test).
Given input and output snapshots might be used in the same test I think input snapshots could have a default filename extension of
.input.snap
so that they don't conflict with the current snapshot file name(s)I'm open to contributing a PR as well!
The text was updated successfully, but these errors were encountered: