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 powerful if jest were to provide a way to create more than one snapshot from a single test source file ... Sometimes its useful to run the same test suite under 'different conditions' and independently track the evolution of some of the snapshots generated within that test suite.
Some examples of different 'conditions' for which it is sometimes desirable to have multiple snapshots derived from a single test definition ..:
some kinds of tests that are expected to produce different results when run in different javascript engines
within applications: sometimes its desirable to run a test-suite relative to different versions of an application deployment environment and independently track the changes in those results
It would be nice to be able to:
define a testingDomainSuffix in globalSetup
allow choosing at the call site when executing a test between the normal .toMatchSnapshot and a .toMatchSnapshot(:withinTestingDomain). The :withinTestingDomain variant would choose the snapshot based on the test file and the defined testingDomainSuffix
I'm thinking something along the lines of ...:
in globalSetup:
specify the list of all possible testingDomainSuffixes: string[] (to support lifecycle management of stale .snap files)
specify the value of testingDomainSuffix for current execution of suite: say "node6" where its enforced that the testingDomainSuffix should belong to the defined list of testingDomainSuffixes expected by the test suite
in foo.test.js expect({foo: 1}).toMatchSnapshot() <-- current behavior -- diffs against value from snapshot file named foo.test.js.snap
in bar.test.js expect({bar: 1}).toMatchSnapshot({withinTestingDomain: true}) <-- diffs against value from snapshot file named bar.test.node6.js.snap
The text was updated successfully, but these errors were encountered:
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.
It would be really powerful if jest were to provide a way to create more than one snapshot from a single test source file ... Sometimes its useful to run the same test suite under 'different conditions' and independently track the evolution of some of the snapshots generated within that test suite.
Some examples of different 'conditions' for which it is sometimes desirable to have multiple snapshots derived from a single test definition ..:
It would be nice to be able to:
I'm thinking something along the lines of ...:
in globalSetup:
in foo.test.js
expect({foo: 1}).toMatchSnapshot()
<-- current behavior -- diffs against value from snapshot file named foo.test.js.snapin bar.test.js
expect({bar: 1}).toMatchSnapshot({withinTestingDomain: true})
<-- diffs against value from snapshot file named bar.test.node6.js.snapThe text was updated successfully, but these errors were encountered: