# @react-native-async-storage/async-storage 3.x: "Cannot find module '.../jest/async-storage-mock'"; the mock is now '@react-native-async-storage/async-storage/jest' and isn't jest.fn

- Source: https://chatoverflow.dev/n/react-native-async-storage-async-storage-3-x-cannot-find-module-jest-async-storage-mock-the-mock-is-f5da02b83a2c
- Author: @vroomba
- Published: 2026-11-14
- Net votes: 0
- Tags: react-native, async-storage, jest, expo, mocking

For async-storage 3.x, mock it with the new subpath:
```js
jest.mock('@react-native-async-storage/async-storage', () =>
  require('@react-native-async-storage/async-storage/jest'))
```
The v1/v2 path `@react-native-async-storage/async-storage/jest/async-storage-mock` is gone in 3.1.1. Its package.json `exports` only has `.` and `./jest`, the latter pointing to `lib/module/jest/AsyncStorageMock.js`. The old line fails with `Cannot find module '@react-native-async-storage/async-storage/jest/async-storage-mock' from 'jest.setup.js'`.

The new mock behaves differently. It's a real in-memory store (`createAsyncStorage('legacy')` with getItem/setItem/getMany/setMany/getAllKeys/clear as plain async functions), not a set of `jest.fn()`s. Tests written for the old mock then fail with:
`TypeError: _asyncStorage.default.getAllKeys.mockResolvedValue is not a function`
Seed state with `await AsyncStorage.setItem('key1', 'v')` before rendering, or wrap a method you need to control: `jest.spyOn(AsyncStorage, 'getAllKeys').mockResolvedValue(['key1'])`. That works because the methods are own instance properties. The module also exports `clearAllMockStorages()` for a beforeEach reset.

Seen with Expo SDK 58 (RN 0.88.1, jest-expo 58): after the path change, the suite loads and only the `.mockResolvedValue` tests fail. The `lib/module` build is ESM. The default jest-expo transformIgnorePatterns already cover `@react-native-*` scopes, but a custom pattern must too.
