首页 > 解决方案 > 修复 ScriptTransformer.js 上的 SyntaxError 从 jest 23.6 更新到 24.1

问题描述

使用 yarn 将 jest 从 23.6 更新到 24.1。获取 SyntaxError: Unexpected identifier import 不管

我尝试更新我认为可能相关的每个节点模块。

-    "@babel/core": "^7.0.0",
-    "@babel/polyfill": "^7.0.0",
+    "@babel/core": "^7.2.2",
+    "@babel/polyfill": "^7.2.5",
     "@types/bluebird": "^3.5.24",
@@ -138,8 +138,7 @@
     "@types/react-dom": "^16.0.9",
     "@types/react-transition-group": "^2.0.14",
     "axios-mock-adapter": "^1.15.0",
-    "babel-core": "^7.0.0-bridge.0",
-    "babel-jest": "^23.6.0",
+    "babel-jest": "^24.1.0",
     "babel-merge": "^2.0.1",
     "babel-plugin-angularjs-annotate": "^0.9.0",
     "babel-plugin-dual-import": "^1.2.1",
@@ -152,7 +151,7 @@
     "expect": "^1.20.2",
     "fake-indexeddb": "^2.0.3",
     "haml": "~0.4.3",
-    "jest": "^23.6.0",
+    "jest": "^24.1.0",
     "jest-junit": "^5.1.0",
     "jest-styled-components": "6.3.1",
     "mini-css-extract-plugin": "^0.4.0",
@@ -166,8 +165,8 @@
     "stylelint-processor-styled-components": "^1.3.2",
     "synchronous-promise": "^2.0.6",
     "thread-loader": "^1.1.5",
-    "ts-jest": "^23.10.4",
-    "typescript": "^3.1.3",
+    "ts-jest": "^23.10.5",
+    "typescript": "^3.3.3",

应该yarn test像以前一样运行。

标签: javascripttypescriptwebpackjestjsbabeljs

解决方案


更新:

问题出在 jest.config.js 我们在内部模块之后声明了 node_modules:

'moduleDirectories': ['our_modules', 'node_modules']

使用新版本,这不再有效。


推荐阅读