我有一个 reactjs(typescript) 应用程序,它使用 monaco-editor-core 而不是 monaco-editor,带有自定义语言。 Jest 测试失败,如果我不模拟 monaco-editor-core 导入,则会出现下一个错误:
"Cannot find module 'monaco-editor-core'",
从我读过的帖子中我了解到 jest 不支持 ESM。这就是编写 monaco-editor-webpack-plugin 的原因,它不适用于 monaco-editor-core。 也许有人知道如何解决 monaco-editor-core 的导入问题以开玩笑?
如果我在 jest.config.js 中使用 moduleNameMapper:
"monaco-editor-core": "<rootDir>/node_modules/monaco-editor-core/esm/vs/editor/editor.api.d.ts"
我有下一个错误:
.../node_modules/monaco-editor-core/esm/vs/editor/editor.api.d.ts:6
declare global {
^^^^^^
SyntaxError: Unexpected identifier at compileFunction (<anonymous>)
如果您需要任何可以提供帮助的其他信息,请发表评论。
PS:我不能将其标记为 monaco-editor-core...
感谢您的帮助!