vendredi 15 décembre 2017

Is it possible to use Enzyme's snapshots on React fragments?

I'm wondering if React fragments are compatible with Enzyme's snapshots. Right now it seems like fragments from React 16+ are being rendered as Symbols in enzyme's shallow() method, which is causes a conversion error:"TypeError: Cannot convert a Symbol value to a string".

Here's my test:

it('should render successfully', () => {
  const wrapper = shallow(
    <Sections
      data={mappedMockData}
      sections={mappedMockData.sections}
      eligibility={mockEligibility}
    />
);

console.log(wrapper.debug());

expect(wrapper).toMatchSnapshot();

And here's the output from my console.log:

  <Symbol(react.fragment)>
    <div className="content-container">
      <div className="flex">
        <div className="sections-wrap">
          <Connect(Section1) />
          <Connect(Section2) />
        </div>
        <Connect(Section3) />
      </div>
    </div>
    <div className="content-container">
      <Connect(Section4) />
      <Connect(Section5) />
    </div>
  </Symbol(react.fragment)>

Worth noting: I've already updated my Enzyme and React, and am already using an adapter, as suggested by enzyme's migration guide. I haven't been able to find other similar issues to this on stack overflow or Github. Thanks in advance for any insights!

Aucun commentaire:

Enregistrer un commentaire