Git Product home page Git Product logo

Comments (19)

adriantoine avatar adriantoine commented on August 31, 2024 9

Thanks for your reports! I'll have a look when I have time

from enzyme-to-json.

KyKyPy3 avatar KyKyPy3 commented on August 31, 2024 3

Yes, the situation has not changed

from enzyme-to-json.

ismay avatar ismay commented on August 31, 2024 3

Ok, I was able to replicate it. The snapshots were created with jest --watch (and then u to update the snapshots). If I then run jest --coverage it fails in this manner:

  ● <Root /> › renders correctly

    expect(value).toMatchSnapshot()

    Received value does not match stored snapshot 1.

    - Snapshot
    + Received

    <BrowserRouter>
    -   <App />
    +   <Component />
      </BrowserRouter>

      at Object.<anonymous> (src/containers/__tests__/Root.test.jsx:13:82)

Results are the same locally and remotely.

from enzyme-to-json.

MoonTahoe avatar MoonTahoe commented on August 31, 2024 2

Until there is a fix on this issue from istanbul...

I found this problem occurs with stateless functional components. You can get the same results with or without coverage in your snapshot tests by setting the .displayName property on stateless functional components.

const MyComponent = () => <div></div>
MyComponent.displayName = "MyComponent"

from enzyme-to-json.

ismay avatar ismay commented on August 31, 2024 1

Yeah it's actually a problem with istanbul: #19 (comment)

from enzyme-to-json.

adriantoine avatar adriantoine commented on August 31, 2024

Hi @KyKyPy3! Thanks for raising the issue, I will have a look as soon as I can.

Can you tell me which version of enzyme-to-json you are using? I wouldn't be surprised if this happens in v1.1.2 but I think I fixed most of these in the latest v1.1.3 version.

from enzyme-to-json.

KyKyPy3 avatar KyKyPy3 commented on August 31, 2024

I try to use 1.1.3 and version build from master branch.

from enzyme-to-json.

adriantoine avatar adriantoine commented on August 31, 2024

@KyKyPy3 any news? Are you trying the latest version?

from enzyme-to-json.

camjc avatar camjc commented on August 31, 2024

Looks like the issue is related to this one
enzymejs/enzyme#611

from enzyme-to-json.

ismay avatar ismay commented on August 31, 2024

I'm running into the same problem, see here: enzymejs/enzyme#640 (comment). I'm using enzyme-to-json 1.3.0, enzyme 2.5.1 and jest 16.0.2

from enzyme-to-json.

ryanewing avatar ryanewing commented on August 31, 2024

Is this in any way related to jamiebuilds/pretty-format@9214857 ?

from enzyme-to-json.

johnthepink avatar johnthepink commented on August 31, 2024

@ryanewing I updated to [email protected] and it didn't fix the issue for me.

from enzyme-to-json.

adriantoine avatar adriantoine commented on August 31, 2024

Is it possible for someone to create a small repo which replicates this issue?

from enzyme-to-json.

ismay avatar ismay commented on August 31, 2024

I've tried, but I'm not able to replicate the issue currently. If I run into it again I'll create an example repo.

from enzyme-to-json.

guijesuis avatar guijesuis commented on August 31, 2024

i have the same issue on my current project. I identified it, as being a miss recognition on component written with lambda (example bellow) that has been instrumented by Istanbul.

 const Root = () =>
   (<Router>
     <App />
   </Router>);

It can be solved by writing using the following syntaxe.

 function Root () {
   return (<Router>
     <App />
   </Router>);
}

But i would prefer if we could fix it.

Is there someone working on it? should i give it a try (may be this week end)?

from enzyme-to-json.

camjc avatar camjc commented on August 31, 2024

For what its worth it appears to effect https://github.com/rogeliog/jest-serializer-enzyme as well, so I guess the fix should be somewhere upstream but I don't know where. Would be great to have a fix :|

from enzyme-to-json.

ismay avatar ismay commented on August 31, 2024

Maybe this is related? gotwarlost/istanbul#699

from enzyme-to-json.

adriantoine avatar adriantoine commented on August 31, 2024

Hi! I'm very late on this issue! I tried running @ismay's example repo, but as far as I can see, it's not related to enzyme-to-json. A quick way to find out is that I tried running:

console.log(wrapper.debug());

in the test and it shows the same component name as the Snapshot:

Debug output:
<BrowserRouter>
  <Component />
</BrowserRouter>

Snapshot:
exports[`<Root /> renders correctly 1`] = `
<BrowserRouter>
  <Component />
</BrowserRouter>
`;

The thing is that I'm just using Enzyme wrappers here to generate snapshots but I can't do more than Enzyme, if the output of .debug() is wrong, enzyme-to-json will be wrong too and it's more likely to be an issue with Enzyme, or Jest, or Istanbul in this case. As @ismay pointed out here, the issue only occurs when the coverage flag is on.

from enzyme-to-json.

tomchentw avatar tomchentw commented on August 31, 2024

@ismay: Yeah it's actually a problem with istanbul:

Exactly!

I've recently encountered this issue and I tried to fix it on the istanbul side. I forked babel-plugin-istanbul to fix this, and I put my discovery in here:

istanbuljs/babel-plugin-istanbul#125

Could you folks let me know what you think about my proposal?

from enzyme-to-json.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.