Jest在OpenLayers导入中遇到意外令牌

问题描述

The Error

Error Soure

我彻底阅读了此错误,并在许多帖子中进行了跟踪,但是解决方案似乎对我不起作用。我读过的潜在原因是:

  1. https://github.com/openlayers/openlayers/issues/7401

我尝试更新package.json中的Jest配置以及已安装的jest-canvas-mock,但仍然遇到此错误。这是我所做的更改:

"transformIgnorePatterns": [
  "<rootDir>/node_modules/(?!(ol)/)"
],"setupFiles": [
  "jest-canvas-mock"
],

在此问题上的任何帮助将不胜感激。

解决方法

深入研究之后,我可以在这里详细了解核心问题:

https://github.com/facebook/jest/issues/6229#issuecomment-551916758

这个问题仍然很重要,因此为了后代,我将提供我发现的应用创可贴的技术:

  1. 将.babelrc重命名为babel.config.js(请注意,您必须使用module.exports)

  2. 应用所需的transformIgnorePattern:

    “ transformIgnorePatterns”:[ “ /node_modules/(?!ol).+\.js$”
    ]

如果这不起作用,上面的链接应引导您寻求解决方案。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...