Jest React Native测试

时间:2020-05-30 00:52:43

标签: javascript reactjs react-native redux jestjs

我的根组件使用AppState并尝试用玩笑来拍摄快照。

运行命令时,我得到以下信息:

$ jest
 FAIL  ./App.test.js (10.276s)
  <App />
    × renders correctly (169ms)

  ● <App /> › renders correctly

    **TypeError: Cannot read property 'match' of undefined**

      60 |
      61 |   getMissingPermissions = () => {
    > 62 |     if (this.state.appState.match(/active/)) {
         |                             ^
      63 |       Promise.all(
      64 |         Object.keys(permissions).map((key) => {
      65 |           return permissions[key].checkPermission().then(({ status }) => {

我该如何解决?

https://reactnative.dev/docs/appstate

0 个答案:

没有答案