Please provide the following:
SDK Version : 48
Platforms(Android/iOS/web/all): All
Add the appropriate “Tag” based on what Expo library you have a question on.
After upgrading to SDK 48 I am getting failed Jest tests and I’m not sure where to start looking. Can anyone understand what is failing when async loading assets.
Seems the issues has arisen because we have gone for a global install of jest cli 26 to 29 during this update.
a useFakeTimer work around now causes tests to lock in 26+ and mocks of font and assets are required covered in this post. There are still a number of issues I am working through so any guidance would be appreciated. I guess running the tests from an npm tasks would make sure we are always using a local version of the jest cli
opened 12:28AM - 28 Feb 23 UTC
Asset
Issue accepted
### Minimal reproducible example
https://github.com/coffeebeats/example-expo-as… set-registry-bug
### Summary
After upgrading from `expo-asset@8.7.0` to `expo-asset@8.8.0`, when trying to load a font via `expo-font` in a `jest` unit test, the font asset module is found to be missing from the `react-native` asset registry. The error is provided below, with the path to the example repository replaced with `<rootDir>`:
> NOTE: This issue reproduces in both `expo@48` and `expo@47`, provided you downgrade the relevant packages (e.g. downgrade `expo-font` to `11.0.1`).
```txt
Error: Module "1" is missing from the asset registry
at Function.fromModule (<rootDir>/node_modules/expo-asset/src/Asset.ts:148:13)
at fromModule (<rootDir>/node_modules/expo-font/src/FontLoader.ts:29:18)
at <rootDir>/node_modules/expo-font/src/Font.ts:130:34
at Generator.next (<anonymous>)
at asyncGeneratorStep (<rootDir>/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (<rootDir>/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
at <rootDir>/node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:7
at new Promise (<anonymous>)
at <rootDir>/node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:12
at apply (<rootDir>/node_modules/expo-font/src/Font.ts:141:2)
at apply (<rootDir>/node_modules/expo-font/src/Font.ts:106:40)
at loadFontInNamespaceAsync (<rootDir>/node_modules/expo-font/src/Font.ts:99:43)
at Array.map (<anonymous>)
at map (<rootDir>/node_modules/expo-font/src/Font.ts:99:29)
at Generator.next (<anonymous>)
at asyncGeneratorStep (<rootDir>/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (<rootDir>/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
at <rootDir>/node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:7
at new Promise (<anonymous>)
at <rootDir>/node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:12
at apply (<rootDir>/node_modules/expo-font/src/Font.ts:104:2)
at apply (<rootDir>/node_modules/expo-font/src/Font.ts:86:32)
at <rootDir>/node_modules/expo-font/src/FontHooks.ts:29:14
at commitHookEffectListMount (<rootDir>/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:12999:26)
at commitPassiveMountOnFiber (<rootDir>/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14422:11)
at commitPassiveMountEffects_complete (<rootDir>/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14382:9)
at commitPassiveMountEffects_begin (<rootDir>/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14369:7)
at commitPassiveMountEffects (<rootDir>/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14357:3)
at flushPassiveEffectsImpl (<rootDir>/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:16248:3)
at flushPassiveEffects (<rootDir>/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:16197:14)
at <rootDir>/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:16012:9
at flushActQueue (<rootDir>/node_modules/react/cjs/react.development.js:2667:24)
at act (<rootDir>/node_modules/react/cjs/react.development.js:2521:11)
at actImplementation (<rootDir>/node_modules/@testing-library/react-native/src/act.ts:30:25)
at renderWithAct (<rootDir>/node_modules/@testing-library/react-native/src/render.tsx:122:6)
at renderWithAct (<rootDir>/node_modules/@testing-library/react-native/src/render.tsx:51:20)
at Object.<anonymous> (<rootDir>/__tests__/App.test.tsx:8:11)
at Generator.next (<anonymous>)
at asyncGeneratorStep (<rootDir>/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (<rootDir>/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
at <rootDir>/node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:7
at new Promise (<anonymous>)
at Object.<anonymous> (<rootDir>/node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:12)
at Promise.then.completed (<rootDir>/node_modules/jest-circus/build/utils.js:293:28)
at new Promise (<anonymous>)
at callAsyncCircusFn (<rootDir>/node_modules/jest-circus/build/utils.js:226:10)
at _callCircusTest (<rootDir>/node_modules/jest-circus/build/run.js:248:40)
at _runTest (<rootDir>/node_modules/jest-circus/build/run.js:184:3)
at _runTestsForDescribeBlock (<rootDir>/node_modules/jest-circus/build/run.js:86:9)
at _runTestsForDescribeBlock (<rootDir>/node_modules/jest-circus/build/run.js:81:9)
at run (<rootDir>/node_modules/jest-circus/build/run.js:26:3)
at runAndTransformResultsToJestFormat (<rootDir>/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:120:21)
at jestAdapter (<rootDir>/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
at runTestInternal (<rootDir>/node_modules/jest-runner/build/runTest.js:367:16)
at runTest (<rootDir>/node_modules/jest-runner/build/runTest.js:444:34)
```
I think the commit that introduced this is #20258, but I haven't yet been able to trace down why this is occurring or how the font module actually gets into the registry successfully in `expo-asset@8.7.0` (assuming that the issue isn't related to a missing mock, or something like that).
A few other points:
- this does *not* occur when running the application in an emulator
- this reproduces on both linux and mac environments
### Environment
expo-env-info 1.0.5 environment info:
System:
OS: macOS 13.2.1
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.14.1 - ~/.volta/tools/image/node/18.14.1/bin/node
Yarn: 3.3.0 - ~/.volta/tools/image/yarn/3.3.0/bin/yarn
npm: 9.3.1 - ~/.volta/tools/image/node/18.14.1/bin/npm
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK:
API Levels: 33
Build Tools: 30.0.3, 33.0.2
System Images: android-30 | AOSP ATD ARM 64 v8a, android-33 | Google APIs ARM 64 v8a
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9514443
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
npmPackages:
expo: 48.0.4 => 48.0.4
react: 18.2.0 => 18.2.0
react-native: 0.71.3 => 0.71.3
Expo Workflow: managed
system
Closed
May 25, 2023, 11:18am
3
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.