Comments (19)
Thanks for your reports! I'll have a look when I have time
from enzyme-to-json.
Yes, the situation has not changed
from enzyme-to-json.
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.
- CI build here: https://gitlab.com/ismay/enzyme-to-json-example/builds/6074425
- Example repo here: https://gitlab.com/ismay/enzyme-to-json-example
from enzyme-to-json.
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.
Yeah it's actually a problem with istanbul: #19 (comment)
from enzyme-to-json.
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.
I try to use 1.1.3 and version build from master branch.
from enzyme-to-json.
@KyKyPy3 any news? Are you trying the latest version?
from enzyme-to-json.
Looks like the issue is related to this one
enzymejs/enzyme#611
from enzyme-to-json.
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.
Is this in any way related to jamiebuilds/pretty-format@9214857 ?
from enzyme-to-json.
@ryanewing I updated to [email protected] and it didn't fix the issue for me.
from enzyme-to-json.
Is it possible for someone to create a small repo which replicates this issue?
from enzyme-to-json.
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.
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.
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.
Maybe this is related? gotwarlost/istanbul#699
from enzyme-to-json.
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.
@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)
- render() returns null for <script> tag HOT 2
- Deep mode includes ForwardRef HOT 6
- Component created using React.memo appears as "Component" in snapshot HOT 5
- Missing displayName for styled-component 4.x HOT 1
- Add @types/enzyme as a dependency HOT 1
- Memo Component as a prop renders as <UNDEFINED /> in snapshot HOT 1
- 3.3.5: TypeError: Cannot convert a Symbol value to a string HOT 1
- mount Fragment with new style (<>...</>) return null HOT 2
- Looking for maintainers HOT 2
- 3.4.1 error -- TypeError: Cannot read property '$$typeof' of undefined HOT 4
- moving from 3.4.0 to 3.4.1 breaks snapshots HOT 3
- Cannot find type definition file for 'cheerio'. HOT 1
- Timestamp key in mock function lead to fail snapshot test HOT 1
- Node crashes when using toJson HOT 7
- ForwardRef included in deep mount
- Allow depth option when serializing mounted wrappers
- JSON changes with each run - React 17 and ReactDOM.createPortal()
- High severity vulnerability found in lodash 4.17.15 HOT 6
- cannot find module 'cheerio' from 'node_modules/enzyme/build/utils.js
- Critical Security Issues Report
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enzyme-to-json.