Unable to test components ought to StatusBarManager.getHeight is not a function site in Expo Project #3524
              
                Unanswered
              
          
                  
                    
                      SalahAdDin
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
We are building a Tile using the Card component.
We write the unit test as follows:
When running it we get:
FAIL app/components/PokemonTile.test.tsx ● Test suite failed to run TypeError: StatusBarManager.getHeight is not a function 1 | import React from "react"; 2 | import { StyleSheet } from "react-native"; > 3 | import { Card, Chip, Text, View } from "react-native-ui-lib"; | ^ 4 | import { TYPE_COLORS } from "../constants"; 5 | import { PokemonDetail } from "../domain/pokemon.model"; 6 | at getHeight (node_modules/react-native-ui-lib/src/commons/Constants.js:30:22) at Object.setStatusBarHeight (node_modules/react-native-ui-lib/src/commons/Constants.js:171:1) at Object.require (node_modules/react-native-ui-lib/src/style/scheme.js:8:1) at Object.require (node_modules/react-native-ui-lib/src/style/colors.js:21:1) at Object.require (node_modules/react-native-ui-lib/src/style/index.js:1:1) at Object.require (node_modules/react-native-ui-lib/src/index.js:1666:14) at Object.require (app/components/PokemonTile.tsx:3:1) at Object.require (app/components/PokemonTile.test.tsx:5:1)To fix it we try mocking the
StatusBarManager.getHeight:But it does not work.
How do you guys test it?
Setup:
Beta Was this translation helpful? Give feedback.
All reactions