Jest-expo expo-constants undefined

  1. SDK Version: 47
  2. Platforms(Android/iOS/web/all): Android/IOS

Hello everyone,

I have an issue with jest-expo and expo-constants. It seems that my expo-constants object is undefined in my tests. I am using some extra variable in my app.config.tsand their are all undefined, that make my tests fail.

The problem with the constants only occure with tests and is working perfectly when launching the app.

My jest config in package.json:

  "jest": {
    "preset": "jest-expo",
    "transformIgnorePatterns": [

Is this a known problem ? My problem looks like this issue Jest Constants.manifest.extra undefined but I couln’t find an answer on it.


I found a solution with jest.mock() as follow:

jest.mock('expo-constants', () => ({
    expoConfig: {
        extra: {
            BUILD_MODE: process.env.BUILD_MODE,

The only constraint was to load my .env with the dotenv package first, I managed to do that with a setupFiles:


export default {
    setupFiles: ['./jest.setup.ts'],
    preset: 'jest-expo',
    transformIgnorePatterns: [


import dotenv from 'dotenv';


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.