TypeError: Cannot read property 'contextTypes' of undefined
See original GitHub issueI have installed enzyme with jest and running test cases as following
describe("Home", () => {
it("should render correctly", () => {
const component = shallow(<Home/>);
});
});
error is: ● Home › should render correctly
TypeError: Cannot read property 'contextTypes' of undefined
5 | describe("Home", () => {
6 | it("should render correctly", () => {
> 7 | const component = shallow(<Home/>);
| ^
8 | });
9 |
10 | });
at Object.render (node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:633:54)
at new ShallowWrapper (node_modules/enzyme/src/ShallowWrapper.js:411:22)
at shallow (node_modules/enzyme/src/shallow.js:10:10)
at Object.it (src/home/Home.test.js:7:27)
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property 'contextTypes' of undefined
Here is an example: AccountFormComponent.jsx (incorrect class name): export class FoeFormComponent extends React.Component { .... }.
Read more >Jest Test Redux Thunk TypeError: Cannot read property ...
Jest Test Redux Thunk TypeError: Cannot read property 'contextTypes' of undefined. export your Component. for example, export const UnConnectedMyComponent ...
Read more >Cannot read property 'contextTypes' of undefined Unit Testing ...
Coding example for the question Cannot read property 'contextTypes' of undefined Unit Testing enzyme-Reactjs.
Read more >Uncaught typeerror: cannot read property 'type' of undefined
Uncaught TypeError: Cannot read property 'type' of undefined ,. Out of the six primitive types defined in JavaScript, namely boolean, string, symbol, number, ......
Read more >typeerror: cannot read property 'location' of undefined jest
A child component is utilizing a tab from material UI, however, every time I run the test the error TypeError: Cannot read property...
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
You need export your component properly, please check your component export. How do you export it?
@ljharb Yes dude, its solve, you right its props undefined, so need to mountWithProvide in the first step. Ya I think this issued should closed, thanks.