callstack / callstack/react-native-pager-view
How to mock this library with jest? (Fails when used normally)
- Ngôn ngữ chính
- TypeScript
- Star
- 3.4k
- Fork
- 476
- Merge trung bình
- 10 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 2
Mô tả
## 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.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với bài kiểm thử tích hợp được mô tả trong issue: render một component bằng ViewPager và gọi setPage trên ref của nó. Điều tra Jest mock hoặc thiết lập kiểm thử xung quanh triển khai ViewPager native và lỗi undefined Commands. Hoàn tất khi bài kiểm thử có thể gọi setPage mà không phát sinh exception.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- react-native
- Lĩnh vực
- mobile, testing-qa
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100