You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/advanced/Jest-integration.md
+21-12Lines changed: 21 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -4,21 +4,24 @@ title: Jest integration
4
4
sidebar_label: Jest integration
5
5
---
6
6
7
-
8
-
Async Storage module is tightly coupled with its `NativeModule` part - it needs a running React Native application to work properly. In order to use it in tests, you have to provide its separate implementation. Follow these steps to add a mocked `Async Storage` module.
7
+
Async Storage module is tightly coupled with its `NativeModule` part - it needs
8
+
a running React Native application to work properly. In order to use it in
9
+
tests, you have to provide its separate implementation. Follow these steps to
10
+
add a mocked `Async Storage` module.
9
11
10
12
## Using Async Storage mock
11
13
12
14
You can use one of two ways to provide mocked version of `AsyncStorage`:
13
15
14
-
### With __mocks__ directory
16
+
### With **mocks** directory
15
17
16
-
1. In your project root directory, create `__mocks__/@react-native-async-storage` directory.
Each public method available from `Async Storage` is [a mock function](https://jestjs.io/docs/en/mock-functions), that you can test for certain condition, for example, if `.getItem` has been called with a specific arguments:
47
+
Each public method available from `Async Storage` is
48
+
[a mock function](https://jestjs.io/docs/en/mock-functions), that you can test
49
+
for certain condition, for example, if `.getItem` has been called with a
50
+
specific arguments:
44
51
45
52
```javascript
46
53
it('checks if Async Storage is used', async () => {
You can [check its implementation](https://github.com/react-native-async-storage/async-storage/blob/master/jest/async-storage-mock.js) to get more insight into methods signatures.
76
+
You can
77
+
[check its implementation](https://github.com/react-native-async-storage/async-storage/blob/master/jest/async-storage-mock.js)
0 commit comments