Regenerating snapshots

What happens if a component has changed? Just for the sake of it, I made a pretty small change to a component. Upon running the tests, I got a FAIL message, with a comparison, that was produced by the usual diff command:

 FAIL src/regionsApp/countryAndRegions.test.js
● App for Regions and Countries › renders correctly

expect(value).toMatchSnapshot()

Received value does not match stored snapshot 1.

- Snapshot
+ Received

@@ -7,11 +7,11 @@
loading={true}
onSelect={[Function]}
/>
</div>
<div>
- Display:
+ Displays:
<RegionsTable
list={Array []}
/>
</div>
</div>

at Object.it (src/regionsApp/countryAndRegions.test.js:31:22)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)

What should you do, then? You should first verify whether the change is correct or not, and in the former case, you could either delete the .snap file (so that it will get regenerated next time) or you can press u, as shown in the test summary:

Snapshot Summary
› 1 snapshot test failed in 1 test suite. Inspect your code changes or press `u` to update them.

Be careful! If you just regenerate the snapshot without verifying that the output is correct, the tests will be worthless; a very bad result!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset