question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
jieliu218commented, Sep 20, 2018

@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 …

1reaction
Dammmiencommented, Sep 25, 2018

@jieliu218 it worked like a charm, thanks !!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found