Skip to main content

All Questions

3 votes
0 answers
805 views

Jest test cases failing due to timeout of react native test library

I am using jest for react-native test cases, after updating to jest v27.5.1, I started getting error for all of the async calls. I solved most of them by following this thread. After this I started ...
Asad Shah's user avatar
0 votes
1 answer
280 views

React native jest: While resolving: [email protected] npm ERR! Found: [email protected]

I am trying to install @testing-library/react-native to a freshly created expo-based react native application. For adding test cases, I followed the steps mentioned in https://docs.expo.dev/guides/...
Sumit Surana's user avatar
  • 1,584
0 votes
1 answer
536 views

Why does Jest sometimes prints "pretty" error messages with line pointers, and sometimes not?

I have jest 27 installed, and I see that sometimes I get pretty error messages like this (with visual pointer to the failing line): And sometimes it prints the errors like this (plain error, without ...
niryo's user avatar
  • 1,615
4 votes
3 answers
6k views

Jest mock dimensions not changing

I am doing testing for the first time so I am pretty much sure that I am doing something wrong. I was writing test case and my component does this internally. const {width, height} = Dimensions.get('...
Alwaysblue's user avatar
3 votes
0 answers
2k views

react native testing library, No instances found with testID

Im getting the error, No instances found with testID: CreateAccount.errorMessage But Im referencing the ID on "CreateAccount.js" <ErrorText text={this.state.errorMessage} ...
manuelBetancurt's user avatar
1 vote
1 answer
717 views

React Native Testing Framework findBy doesn't find and waitFor doesn't wait

This is an image gallery and I'm confident it's working correctly. It runs fine in the simulator. I've tried to variations of the same test: test('main image should display', async () => { ...
Matthew Jones's user avatar
11 votes
2 answers
25k views

"SyntaxError: Cannot use import statement outside a module" error while testing React Native project with Jest and @testing-library/react-native?

Error I'm getting Anytime I run npm test: FAIL ./App.test.js ● Test suite failed to run Jest encountered an unexpected token This usually means that you are trying to import a file which Jest ...
Ben Estes's user avatar
  • 113
1 vote
0 answers
100 views

React-Native-Testing-Library 'warning - an updated was not wrapped in act(...)

I think this question has been asked, but no solution was provided. I'm using RNTL trying to unit test a simple RN component. My example below: component = render(<ThemeProvider> <...
Alexandra Nicolau's user avatar
4 votes
0 answers
2k views

expect(jest.fn()).toHaveBeenCalledWith(...expected) in react-native and expo

I'm trying to write the unit test for the Controller which is written in react-native and expo Following is the login method for which Unit test is failing login.tsx import React, { useState } from '...
ann kim's user avatar
  • 41
0 votes
1 answer
476 views

jest error: const warnedKeys: {[string]: boolean} = {};

If I run yarn test, which runs jest, I get the following error: C:\react-native-project\node_modules\react-native\Libraries\Utilities\warnOnce.js:15 const warnedKeys: {[string]: boolean} = {}; ...
haleonj's user avatar
  • 1,518