react-native - 使用 Jest 运行测试时无法忽略 node_module 中的包
问题描述
尽管配置了 Jest,但我在设置 jest 并运行测试时遇到了这个问题
TypeError: Cannot read property 'Constants' of undefined
at Object.<anonymous> (node_modules/@momo-platform/component-kits/components/qrcodeScanner/QRCodeScannerView.js:1:2882)
at Object.<anonymous> (node_modules/@momo-platform/component-kits/index.js:1:22069)
console.error node_modules/prop-types/factoryWithTypeCheckers.js:23
Warning: Invalid arguments supplied to oneOf, expected an array, got 3 arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).
这是配置文件 jest.config.js:
module.exports = {
preset: 'react-native',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
cacheDirectory: './cache',
// "coveragePathIgnorePatterns": [
// "./app/utils/vendor"
// ],
coverageThreshold: {
global: {
statements: 80,
},
},
moduleNameMapper: {
'.+\\.(png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
},
transformIgnorePatterns: [
'node_modules\/(?!(react-native|react-native-camera-kit|react-native-linear-gradient|react-native-iphone-x-helper|react-native-progress|@react-native-community|@momo-platform/component-kits/components/qrcodeScanner/QRCodeScannerView.js))(.*)',
],
};
大家可以帮我忽略 node_modules 中的 node_modules/@momo-platform/component-kits 问题吗?
解决方案
推荐阅读
- python-3.x - 使用 for 循环在熊猫中创建一个新列?
- c# - 如何修复 C# 中的“方法的类型签名与 PInvoke 不兼容”错误
- odoo - 在 Odoo 11 中,在看板视图中,readonly attr 不起作用
- wordpress - 编辑 php.ini 不会解决 Amazon Linux 2 上内存限制 2mb (wordpress) 的问题
- php - Woocommerce 管理员产品编辑页面导航
- php - 我应该在我的股票交易(买卖股票)网站(wordpress 网站)中使用哪个 API?
- mysql - InnoDB:标题页由数据文件中的零字节组成:./ibdata1
- matlab - 堆栈图 MatLab 中的对数 x 轴
- oracle - 如何检查我们的查询是否在 Oracle 数据库中进行了转换?
- dart - 如何等待 openRead 函数在一个文件上完成,然后再继续下一个文件?