question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

testing components with enzyme

See original GitHub issue

Hi guys, Thanks for great work in NativeBase. My project looks like this: react-native 0.51.0 native-base 2.3.5 emzyme 3.3.0 jest 20.0.4

I’m having difficulty using enzyme to render my components. What I’m trying to achieve is to render a component, which has included a number of NativeBase components. I’m encountering several warnings for instance:

Warning: <Text /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.

and

Warning: React does not recognize theallowFontScalingprop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercaseallowfontscalinginstead. If you accidentally passed it from a parent component, remove it from the DOM element. in Text in Text (at Text.js:30) in Text in Styled(Text)

My guess is that enzyme was not able to determine correct environment and thinks we are in React. any hints what should I do to fix this?

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
i-olivacommented, Dec 19, 2018

Having the same issue. Apparently the tests run good, but the warning does appear.

0reactions
Macht59commented, May 19, 2020

Following solved the problem for me

it('has appropriate title', () => {
    const wrapper = shallow(<MyHeader title="title123" />);
    expect(wrapper.contains(<Title>title123</Title>)).toBe(true);
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing React with Jest and Enzyme I - Medium
Enzyme is a JavaScript Testing utility for React that makes it easier to assert, manipulate, and traverse your React Components' output.
Read more >
Introduction · Enzyme - GitHub Pages
Enzyme is a JavaScript Testing utility for React that makes it easier to test your React Components' output. You can also manipulate, traverse,...
Read more >
How to Test React Components using Jest and Enzyme
Without Jest, there is no way to run Enzyme tests. Enzyme adapter is required to provide compatibility to different React versions.
Read more >
React Unit Testing Using Enzyme and Jest - Toptal
In this post, we will use Jest and Enzyme to create a React.js component with basic functionality using TDD.
Read more >
How to test React with Jest & Enzyme - Robin Wieruch
Enzyme makes it effortless testing React components with integration and unit tests. It is a testing library by Airbnb which got introduced ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found