Testing with Jest
See original GitHub issueQuestion
I am having hard times trying to figure out how to write tests for forms using the datetime picker component and I couldn’t really find any examples online. Wouldn’t it be useful to include a simple example in the docs? I am using jest
and react-native-testing-library
. The problem is that every time I open the datetime picker in my tests it throws an error: TypeError: this._picker.current.setNativeProps is not a function
.
I am not really sure if I can mock this call out or what the recommended approach would be.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Jest · Delightful JavaScript Testing
Jest is a JavaScript testing framework designed to ensure correctness of any JavaScript codebase. It allows you to write tests with an approachable, ......
Read more >Jest Tutorial for Beginners: Getting Started With JavaScript ...
Jest is a JavaScript test runner, that is, a JavaScript library for creating, running, and structuring tests. Jest ships as an NPM package,...
Read more >Jest Tutorial - JavaScript Unit Testing Using Jest Framework
Jest is a Javascript Testing framework built by Facebook. It is primarily designed for React (which is also built by Facebook) based apps...
Read more >Jest Testing Tutorial: 5 Easy Steps - Testim Blog
1. Install Jest Globally · 2. Create a Sample Project · 3. Add Jest to the Project · 4. Write Your First Test...
Read more >What Is Jest – A Tutorial on How to Use Jest - LambdaTest
Jest is a testing framework that allows you to write tests in an approachable, familiar, and feature-rich API. Jest provides quick test results...
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 FreeTop 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
Top GitHub Comments
FYI this works to mock (https://jestjs.io/docs/en/tutorial-react-native#mock-native-modules-using-jestmock)
const timePicker = await component.findByTestId(‘dateTimePicker’); fireEvent(timePicker, ‘onChange’, { nativeEvent: { timestamp: ‘01/01/1976’ } });