I started adding unit tests to our Expo project.
I’m having problem with testing a method that ask for location permission and locates the user.
The error:
TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at keys (node_modules/expo-permissions/src/Permissions.js:15:20)
at call (node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.tryCatch [as _invoke] (node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:271:22)
at Generator._invoke [as next] (node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:97:21)
at call (node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:45:40)
at tryCatch (node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:135:20)
at invoke (node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:145:13)
at fn (node_modules/promise/lib/core.js:37:12)
at tryCallOne (node_modules/promise/lib/core.js:123:15)
The line for asking permission:
const { status } = await Permissions.askAsync(Permissions.LOCATION);
I’d like to know what is the recommended way of testing these kind of methods?
Expo SDK: 32.0.0
jest-expo: 32.0.0