callstack / callstack/react-native-pager-view

How to mock this library with jest? (Fails when used normally)

Aperta
#481 7 commenti 8 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
3.4k
Fork
476
Merge medio
10g 21h
PR unite (30g)
2

Descrizione

## Environment

Relevant versions:

```json
"react": "17.0.2",
"react-native": "0.66.0",
"react-native-pager-view": "^5.4.9",
```

## Description

Calling the `setPage` method on a viewPager `ref` causes jest to throw this error:

```
TypeError: Cannot read properties of undefined (reading 'Commands')

87 | if (viewPager.current) {
> 88 | viewPager.current.setPage(page);
| ^
89 | }
90 |
```

## Reproducible Demo

1. Create an integration test with any component using `ViewPager` and call `setPage` on it's ref. This error will throw.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.