Comments (8)
Hi sorry for the late reply. I'm going to work on it this week.
from native-testing-library.
Hi @manakuro,
I've not personally used baseElement
before, but judging by your intentions in the tests, you're probably after using the named export toJSON
from the library like so:
import 'react-native'
import React from 'react'
import App from 'app/src/App'
import { render, toJSON } from '@testing-library/react-native'
it('renders correctly', () => {
const { baseElement } = render(<App />)
expect(toJSON(baseElement)).toMatchSnapshot()
})
If that doesn't work, try using container
instead of baseElement
- it's probably a better option for your use case:
import 'react-native'
import React from 'react'
import App from 'app/src/App'
import { render, toJSON } from '@testing-library/react-native'
it('renders correctly', () => {
const { container } = render(<App />)
expect(toJSON(container)).toMatchSnapshot()
})
Hope that helps!
from native-testing-library.
Thanks for jumping in Lewis π
@manakuro sorry for the delay. So, this one just looks like an issue with the typings actually. Iβm not a typescript user myself, so would you mind helping out by creating a PR to fix the type issues youβre running into? I can support that effort however necessary to allow these to be correct π―
After the typings are fixed, what you did should work. Until the typings are fixed, even what Lewis suggested wonβt work without compile errors.
from native-testing-library.
Hi @lewie9021
Thank you for your suggestions. I tried to use container
and toJSON
as you said but there still are a typing error.
@bcarroll22 Hi, thank you for the reply. Okay I'll create a PR to fix it. π
Thank you for your guys help οΌ
from native-testing-library.
Awesome! Thanks for your help. I should be able to get it reviewed and merged today.
from native-testing-library.
Hi, any update on this?
from native-testing-library.
@manakuro No worries at all, I just didn't see an update and was worried I'd missed something :)
from native-testing-library.
π This issue has been resolved in version 4.0.3 π
The release is available on:
npm package (@latest dist-tag)
- GitHub release
Your semantic-release bot π¦π
from native-testing-library.
Related Issues (20)
- Preset with Expo in install doc is out of date HOT 3
- Support for fire Scrollview onScroll events HOT 1
- query does not work in react-native and apollo HOT 3
- fix act warning on latest react native version v62 when running multiple tests HOT 2
- How do I use getByText without it getting hung up on a <Image> inside the <Text>? HOT 3
- How should drag events be simulated? HOT 1
- ValueChange does not work as expected with Picker HOT 3
- "Unable to find an element with the value" with Picker HOT 2
- View's 'measure' method callback not invoked HOT 1
- Cannot convert undefined or null to object at assign (<anonymous>) HOT 13
- Check disabled button HOT 2
- View's `measure` + other native methods are null HOT 2
- Help with test setup HOT 1
- Test failures related to LogBox HOT 3
- Test failure after 0.63 HOT 2
- Support Installation via Git Dependency HOT 1
- Add upcoming deprecation to project README HOT 5
- fireEvent.layout doesn't trigger onLayout for TouchableOpacity HOT 2
- queryByTitle missing? HOT 1
- v6.0.0 don't works with react-native 0.61.5 HOT 2
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 native-testing-library.