jestjs - 与 Babel 开玩笑 ^7.0.0-beta.51 问题
问题描述
我遵循了您建议我使 Babel 7 与 Jest 一起工作的所有内容。我安装了@babel/core
和babel-core
。仍然它不起作用。
{
"devDependencies": {
"@babel/cli": "^7.0.0-beta.51",
"@babel/core": "^7.0.0-beta.51",
"@babel/node": "^7.0.0-beta.51",
"@babel/plugin-transform-modules-commonjs": "^7.0.0-beta.51",
"@babel/preset-flow": "^7.0.0-beta.51",
"babel-core": "^7.0.0-beta.51",
"jest-cli": "^23.1.0"
}
}
后yarn jest
yarn run v1.9.0-20180612.1255
$ /Users/m/Desktop/k/node_modules/.bin/jest
FAIL packages/services/src/Client/__tests__/Client.js
- Test suite failed to run
Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.
at throwVersionError (node_modules/@babel/helper-plugin-utils/lib/index.js:65:11)
at Object.assertVersion (node_modules/@babel/helper-plugin-utils/lib/index.js:13:11)
at _default (node_modules/@babel/plugin-transform-modules-commonjs/lib/index.js:51:7)
at node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
at Array.map (<anonymous>)
解决方案
看到你关于 Jest GitHub 问题的问题——我认为是你,但我最终通过浏览create-react-app
repo并查看他们如何集成 Jest 解决了这个问题。具体来说,该packages/react-scripts/package.json
文件包含您需要的内容。
"@babel/core": "7.0.0-beta.46",
"@babel/runtime": "7.0.0-beta.46",
"autoprefixer": "8.5.0",
+ "babel-core": "7.0.0-bridge.0",
"babel-eslint": "8.2.3",
"babel-jest": "22.4.3",
添加带有+
, 的行或更改您拥有的版本,您应该会很好。
推荐阅读
- .net - 对解决方案的任何更改都会产生 CefSharp“找不到文件”错误
- node.js - mongoose suppressWarning 选项
- javascript - 显示输入颜色选择器时无法输入输入文本
- sql - BigQuery,使用 ARRAY_AGG 创建逗号分隔的结果
- asp.net-core - Blazor Webassembly 和 OData(命名空间 Microsoft.Aspnetcore 中不存在 MVC)
- java - Oracle SQL Developer 不会连接到本地数据库,OCI 库不会加载
- graphdb - 不允许使用空 uri
- javascript - 数据在屏幕上呈现,但在控制台上有错误(Firebase with Vue):未捕获(承诺中)TypeError:无法读取 null 的属性“内容”
- vuetify.js - vuetify 数据表在 th 上插入输入
- talend - Talend 7.3:如果任何列值不同,则更新行