snapshot tests failing with `Cannot read property 'split' of null`
See original GitHub issueDescription
When snapshots do not match a type error is thrown instead of the diff. TypeError: Cannot read property 'split' of null
.
Test Source
import React from 'react';
import test from 'ava';
import { render } from 'enzyme';
const TestMe = ({ me }) => (
<div>
<p>{me}</p>
</div>
);
test('renders the component', t => {
const wrapper = render(<TestMe me='change me' />);
t.snapshot(wrapper.html());
});
Error Message & Stack Trace
Warning: ReactTestUtils has been moved to react-dom/test-utils. Update references to remove this warning.
✖ renders the component Error thrown in test
1 test failed [11:04:02]
renders the component
/path/to/example.test.js:13
12: const wrapper = render(<TestMe me='change us' />);
13: t.snapshot(wrapper.html());
14: });
Error thrown in test
Error:
[TypeError: Cannot read property 'split' of null]
Config
Copy the relevant section from package.json
:
{
"ava": {
"require": [
"babel-register",
"./test-environment.js"
],
"babel": "inherit",
"files": [
"**/*.test.js",
"!node_modules"
]
}
}
Command-Line Arguments
Copy your npm build scripts or the ava
command used:
ava --verbose path/to/example.test.js
Relevant Links
https://gist.github.com/pho3nixf1re/4c23d77709ce4ef044ebae7c937940ec
Environment
Node.js v7.10.0
darwin 16.5.0
AVA 0.19.1
npm 4.2.0
yarn v0.23.4
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Cannot read property 'split' of undefined while testing getting ...
vuejs2 - Cannot read property 'split' of undefined while testing getting this error - Stack Overflow. Stack Overflow for Teams – Start ...
Read more >typeerror: cannot read property 'useeffect' of null - You.com | The ...
Firebase ReactJS useEffect TypeError: Cannot read property 'uid' of null ... made in a hook and that hook was used in the component...
Read more >Npm start doesn't work - M220JS - MongoDB
after trying your commands, I'm getting Cannot read property 'split' of null error :cold_sweat: Fabii_08776 (Fabio Almeida Caetano) August ...
Read more >TypeError: Cannot read property 'has' of undefined - Help
In your case, jsonData doesn't have the data property, so trying to access data's own username property will cause an error, not simply...
Read more >Jest unit test fails with Error: Uncaught [TypeError: Cannot ...
Forum Thread - Jest unit test fails with Error: Uncaught [TypeError: Cannot read property 'id' of undefined] - React - EJ 2.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For those who end up here looking for a fix, you can delete the corresponding entry in the
__snapshots__/
folder. You lose your snapshot history but it will fix the bug#1341 has landed. A new release will be out soon.