callstack / callstack/react-native-pager-view

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

Open
#481 7 comments 8 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.4k
Forks
476
Avg merge
10d 21h
Merged PRs (30d)
2

Description

## 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.