adriantoine / enzyme-to-json

Snapshot test your Enzyme wrappers
MIT License
947 stars 64 forks source link

Snapshot issue for Fragment #111

Closed Mayank009 closed 6 years ago

Mayank009 commented 6 years ago

Two different snapshots are getting generated using shallow for below component

Component: `import React, { Component, Fragment } from 'react';

` **Snapshot 1**: `
` **Snapshot 2**: `
` What could be the possible reason for in first and in latter for same component?
Mayank009 commented 6 years ago

When I debugged component for both snapshots I got outputs as below.

Note: I used debug function as below const component = shallow(<AppLayout />); component.debug();

Snapshot 1 <Symbol(react.fragment)><Header location={{...}} matchUrl="/practices/test_9995" /><section className="ps"><Switch><Route path="/practices/test_9995/topics" component={[Function: Connect]} /><Route path="/practices/test_9995/people" component={[Function: Connect]} /><Route path="/practices/test_9995/tools-and-frameworks" component={[Function: Connect]} /><Route path="/practices/test_9995" component={[Function: Connect]} /></Switch></section></Symbol(react.fragment)>

Snapshot 2

<Fragment><Header location={{...}} matchUrl="/practices/test_9995" /><section className="ps"><Switch><Route path="/practices/test_9995/topics" component={[Function: Connect]} /><Route path="/practices/test_9995/people" component={[Function: Connect]} /><Route path="/practices/test_9995/tools-and-frameworks" component={[Function: Connect]} /><Route path="/practices/test_9995" component={[Function: Connect]} /></Switch></section></Fragment>

Any help on how can I debug reason for <Symbol(react.fragment)> in first whereas in latter debug output?

bsingr commented 6 years ago

We are facing the same problem here. However, we get different results on different test machines:

@Mayank009, what OS and npm-package versions do you run?

bsingr commented 6 years ago

Just curious, could this be due to difference between those two:

Mayank009 commented 6 years ago

@bsingr, Snapshot 1: OS: MacOS Npm Version: 6.3.0 Snapshot 2: OS: Alpine (Docker Container) Npm Version: 5.6.0.

SamSamskies commented 6 years ago

I had this same issue. For the machine producing snapshot 1, make sure you update to the latest enzyme (v3.4.1), enzyme-to-json (v3.3.4), and enzyme-adapter-react-16 (v1.2.0). That fixed it for me. Not sure which package was causing the issue as I updated all of them at the same time. Also, not sure why my machine was out of sync with my CI server despite having a package-lock.json.

Mayank009 commented 6 years ago

@SamSamskies it's fixed now. Thanks.