Questions tagged [jest-expo]

11 questions
1
vote
1 answer

@testing-library/react-native -> render -> "TypeError: Cannot read properties of undefined (reading 'exists')"

I've looked through many similar questions, but none seem to be facing the same issue I am having... ScreenLogin.test.tsx import React from 'react'; import { render, screen } from '@testing-library/react-native'; import ScreenLogin from…
Fiddle Freak
  • 1,923
  • 5
  • 43
  • 83
1
vote
0 answers

react native unit test: received value must be an HTMLElement or an SVGElement

I am new to react native (expo) and to unit testing. I have been trying to test the style of a custom text component but many of the jest matchers aren't working. This is the custom text component: import { styled } from 'nativewind'; import React…
1
vote
0 answers

Jest-expo all tests fail after update to SDK 47

Before update my expo project to SDK 47, all test suites worked as a charm. But now I'm getting these kind of errors that I don't know how to solve it. I've noticed those packages are written now with TS. Maybe the error is going around this. Do I…
1
vote
0 answers

react-native-web jest mock works for ios but not web

In a react-native-web/expo setup, during tests using jest with jest-expo, web and ios config, the following mock always seems to be 0 in web yet 300 in ios. The test: import { renderHook } from '@testing-library/react-hooks' import { useOrientation…
conor909
  • 1,475
  • 14
  • 29
1
vote
0 answers

How to mock an async redux action in jest?

I'm using jest in my expo project for unit testing. I am new to jest I don't know how to use mock functions to test my redux actions.Following is my action for SignIn. authActions.ts .. import Api, { SubscriptionPreference, } from…
Linu Sherin
  • 1,712
  • 7
  • 38
  • 88
0
votes
1 answer

@testing-library/react-native mock axios post timesHaveBeenCalled(1) is 0

I need help figuring out how to mock an axios post request. The docs have failed me. I've tried just about every combination I could find on stack overflow. All end up with either typescript errors or the undesired results shown below... The…
0
votes
1 answer

Module '"@testing-library/react-native"' has no exported member 'waitForElement'

Not sure why this is happening when the docs say it's okay to use this: https://www.tabnine.com/code/javascript/functions/%40testing-library%2Freact-native/waitForElement App.test.tsx import React from 'react'; import { waitFor, waitForElement }…
Fiddle Freak
  • 1,923
  • 5
  • 43
  • 83
0
votes
1 answer

Having trouble to test my component with ref using react-native-testing-library and react-native-reanimated

I am trying to test my toast component (uses react-native-reanimated under the hood) using react-native-testing-library but when I try to show my toast the ref is null. I cannot understand why: This is my test scenario: import React from…
0
votes
1 answer

What for incompatibility between babel-proposal-decorators and typescript-decorator?

I recently rewrite CyriacBr/class-fixtures-factory with updating libraries version at https://github.com/MOCHI-inc-JAPAN/class-fixtures-factory. I succeeded running it in ts-jest environment, but switch jest-expo, doesn't work. I suspect decorator's…
tkowt
  • 185
  • 1
  • 13
0
votes
1 answer

React & React Native Testing Library wait for async state update caused by useEffect on mount

I can't seem to get this simple test to work in react-testing-library & react-native-testing-library. I've tried various combinations of wrapping the render function in act, or using waitFor and other async utils, but the test never waits for the…
0
votes
2 answers

React-Navigation V6 Drawer.Item drawerItemStyle: { display: "none" } still renders DrawerItem in react-test-renderer

I am trying to write a test where Drawer item goes from invisible to visible. The way I am implementing the visibility switch is by toggling the drawerItemStyle prop on the Drawer item from display: "none" to display: "flex". This works in an…