首页 > 解决方案 > 无法用 jest 运行 react-native 测试

问题描述

jest 在 react-native 0.61.5 上一直失败

https://github.com/mindsgn/OrbytDapp/issues/8

yarn run v1.21.1 $ jest FAIL tests /App-test.js ● 测试套件运行失败

ReferenceError: __DEV__ is not defined

  3 |  */
  4 | 
> 5 | import 'react-native';
    | ^
  6 | import React from 'react';
  7 | import App from '../App';
  8 | 

  at Object.<anonymous> (node_modules/react-native/Libraries/react-native/react-native-implementation.js:353:1)
  at Object.<anonymous> (__tests__/App-test.js:5:1)

测试套件:1 个失败,总共 1 个测试:总共 0 个快照:总共 0 个时间:2.597 秒运行所有测试套件。error 命令失败,退出代码为 1。 info 访问https://yarnpkg.com/en/docs/cli/run以获取有关此命令的文档。

标签: typescriptreact-nativejestjs

解决方案


推荐阅读