首页 > 解决方案 > 为什么我使用玩笑得到未知选项“extensionsToTreatAsEsm”

问题描述

这里的文档看来,我应该能够将以下内容添加到我的 jest 配置extensionsToTreatAsEsm: [".js", ".mjs"],中。但是当我跑步时,我得到

Unknown option "extensionsToTreatAsEsm" with value [".js", ".mjs"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

我在,latest所以我错过了什么?

标签: jestjs

解决方案


我得到了同样的错误,似乎它仍然是实验性的,我的构建在 GitHub 上失败了。目前我没有使用本机 ESM 模块配置jest.config.js

extensionsToTreatAsEsm [数组<字符串>]

Jest will run .mjs and .js files with nearest package.json's type field set to module as ECMAScript Modules. If you have any other files that should run with native ESM, you need to specify their file extension here.

Note: Jest's ESM support is still experimental,

推荐阅读