reactjs - 反应笑话测试中意外令牌导入错误
问题描述
我的 jest.config.js
文件包含下面给出的数据。
但是当我运行测试命令时,它给了我 SyntaxError 错误:
意外的令牌导入
当我触发测试命令时出现错误
const path = require('path');
module.exports = {
bail: true,
rootDir: process.cwd(),
testRegex: '/__tests__/.*\\.test\\.jsx?$',
transform: { '/__tests__/.*': path.resolve(__dirname, 'jest.transform.js'),},
verbose: true,
};
解决方案
请安装"babel-jest": "^23.0.1",
并添加以下转换配置:
const path = require('path');
module.exports = {
bail: true,
rootDir: process.cwd(),
testRegex: '/__tests__/.*\\.test\\.jsx?$',
"transform": {
"\\.js$": "<rootDir>/node_modules/babel-jest"
},
verbose: true,
};
让我知道问题是否仍然存在
推荐阅读
- firebase - Firebase 使用电子邮件链接登录,并在颤动中提供 ERROR_UNAUTHORIZED_DOMAIN
- asp.net-core - 了解 ASP.NET Core 补丁版本前滚
- swift - 如何用字符串引用节点?
- html - 在 django tables2 中设置动态表的最佳方法(例如 Meta 类)
- timer - angular7中的rxjs计时器
- mysql - 请帮助 :( SQL 问题!在 case 语句中选择不同的语句
- php - 权限被拒绝 - 取消链接文件
- python - 实现 numpy.isin 后跟 sum 的更快方法
- c - 屏幕截图 Windows.UI.Core.CoreWindow 沉浸式 UWP
- python - 如何解决无法正确复制的元胞自动机/空间囚徒困境