我正在尝试使用 TypeScript 在 Preact 应用程序中使用 Jest 和酶运行测试。
\n\n我收到 Jest 遇到意外令牌错误:
\n\nFAIL src/app/app.test.tsx\n \xe2\x97\x8f Test suite failed to run\n\n Jest encountered an unexpected token\n\n This usually means that you are trying to import a file which Jest cannot parse, \n e.g. it\'s not plain JavaScript.\n...\n Details:\n\n src/app/app.test.tsx:10\n const wrapper = enzyme_1.mount(<app_1.default optOutUrl="none"/>);\n ^\n\n SyntaxError: Unexpected token <\n\n at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1059:14)\nRun Code Online (Sandbox Code Playgroud)\n\n在看到此存储库中的TypeScript 示例后,我更改了 jsx 选项以在tsconifg.json. 但它对我的项目环境没有帮助:
Cannot find module \'react\' from \'styled.js\'\n\n However, Jest …Run Code Online (Sandbox Code Playgroud)