我正在尝试向使用 ts-Jest/Jest 和 Chai 用 TypeScript 编写的 Electron + Vue2 应用程序添加测试。但是,当我尝试运行我编写的简单测试以尝试确保 Jest 正常工作时,我现在遇到了 Jest 的问题,似乎不喜欢我正在导入我正在测试的组件模板这一事实可以在错误中看到。当我尝试搜索与此相关的内容时,我运气不佳,其中很多都指向“意外的令牌导入”,这是我已经解决的问题。
如果有人对我如何让测试不害怕导入 HTML 有任何见解或知识,那将是惊人的,因为我很难过,而且文档似乎没有指出任何有用的东西。
错误:
$ npm run test
> app@1.0.0 test C:\Users\daniel\Desktop\app\app
> jest --detectOpenHandles
FAIL src/app/features/app-window/app-window.component.spec.ts
? Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring …Run Code Online (Sandbox Code Playgroud)