lifecycles Object added to adapter snapshots
See original GitHub issue🤔
After writing some tests for a component (which all passed ✅) I ran the entire test suite. Firstly it seems to have added a lifecycles
Object too all of my snapshots. Even though I haven’t actually changed any other components. On the diff I see this received lines:
+ "lifecycles": Object {
+ "componentDidUpdate": Object {
+ "onSetState": true,
+ },
+ "getDerivedStateFromProps": true,
+ "getSnapshotBeforeUpdate": true,
+ "setState": Object {
+ "skipsComponentDidUpdateOnNullish": true,
+ },
+ },
},
},
+ "attachTo": undefined,
+ "hydrateIn": undefined,
Versions
I’m running: Node Version 10.9
and Jest ^22.4.3
.
Expected behavior
I would expect it just to fail the snapshot from the component I changed. Then update the snapshot and it should work.
Console Output (when running test suite)
Received value does not match stored snapshot 1.
- Snapshot
+ Received
@@ -1,7 +1,6 @@
ShallowWrapper {
- "length": 1,
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <MyComponent
clearSuggestions={[Function]}
fetchSuggestions={[Function]}
id="address-lookup"
@@ -318,9 +317,21 @@
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
+ "lifecycles": Object {
+ "componentDidUpdate": Object {
+ "onSetState": true,
+ },
+ "getDerivedStateFromProps": true,
+ "getSnapshotBeforeUpdate": true,
+ "setState": Object {
+ "skipsComponentDidUpdateOnNullish": true,
+ },
+ },
},
},
+ "attachTo": undefined,
+ "hydrateIn": undefined,
},
}
26 | />
27 | );
> 28 | expect(addressLookupWrapper).toMatchSnapshot();
29 |
30 | addressLookupWrapper.unmount();
31 |
at Object.toMatchSnapshot (src/tests/MyComponent.test.js:28:34)
› 1 snapshot test failed.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11
Top Results From Across the Web
Handling Lifecycles with Lifecycle-Aware Components
Lifecycle is a class that holds the information about the lifecycle state of a component (like an activity or a fragment) and allows...
Read more >Amazon Data Lifecycle Manager
Use Amazon Data Lifecycle Manager to create, retain, and delete Amazon EBS snapshots and EBS-backed AMIs.
Read more >Managing Connector Lifecycle
Managing a connector lifecycle includes installation, configuration, and cloning of connectors. After a connector is installed and configured successfully, ...
Read more >Saving FirebaseUI RecyclerView state - Alex Saveau
Under the hood, the adapter is actually building a backing observable snapshot array. That's a lot of fancy words, so let's parse them...
Read more >How can we get entire object list passes to the ...
You can use adapter.snapshot().items . More info can be found here.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Matt-Owens @Dammmien
I solve this issue by removing the node_modules, and run yarn install, then generate new yarn.lock and test snapshot.
Before I use npm install, something wrong here …
@jieliu218 it worked like a charm, thanks !!