测试因 SyntaxError 失败:意外的令牌导出

use*_*060 5 jestjs

将包“office-ui-fabric-react”从“5.124.0”更新到“6.128.0”后,我所有的测试都失败并出现以下错误:

 FAIL  src\***.test.tsx
  ? Test suite failed to run

\node_modules\office-ui-fabric-react\lib\Callout.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export * from './components/Callout/index';
                                                                                         ^^^^^^

SyntaxError: Unexpected token export

  at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:289:17)
Run Code Online (Sandbox Code Playgroud)

edb*_*ley 0

export用于 ES 模块,而 Jest 因为在 Node 中运行,所以需要通用的 JS 模块。请参阅TransformIgnorePatterns上的文档,了解如何使用 TypeScript 设置将其转换为常见 JS。