typescript - 无法用 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以获取有关此命令的文档。
解决方案
推荐阅读
- javascript - React 组件未使用地图功能呈现
- javascript - if 语句和 ajax 调用的代码执行顺序
- composer-php - 将私有 GitLab 存储库与 Composer 一起使用
- azure-devops - 如何通过 CredentialProvider.VSS.exe 清除凭证缓存
- javascript - 纯函数可以使用 `this` 改变其容器类中的其他属性吗?
- css - 如何在 React Native Project 中的图像之间留出空间?
- ios - 如何选择要在 Nativescript 中使用的 Swift 编译器版本?
- javascript - Electron-Builder Updater 只是卸载当前安装
- python - Django上的按钮点击调用功能视图
- python - 递归检查数组中的新元素并触发动作