我正在尝试使用Jest在React应用程序中进行测试;我的应用程序使用Vite作为模块绑定器。问题是,每次运行测试时,我都会得到以下错误:
> react-test@0.0.0 test
> jest
FAIL src/test/App.test.jsx
● Test suite failed to run
Jest encountered an unexpected token
Jest failed to parse a file. This happens e.g. when your code or its dependencies us
我目前正在试验我的新反应项目使用React和GraphQL阿波罗的一个问题。这是我的堆栈:
Webpack将建/开发到项目
Babel到transpile javascript/jsx文件
开玩笑地运行测试
用酶来测试我的反应成分
问题是:当我运行测试时,阿波罗react客户端似乎没有被转移并抛出测试:
pp/containers/App/__tests__/App.test.jsx
● Test suite failed to run
/Users/utilisateur/Project/TrAVis/TrAVis/node_modules/react-
当尝试编译我的服务器端代码时,我得到以下错误:
Module parse failed: (...babel-loader-path)?{"presets":["es2015-node4","es2015"]} (...) Unexpected token (86:6)
You may need an appropriate loader to handle this file type.
这个错误似乎是由我试图导入的异步函数引起的。我需要更改我的webpack配置吗?
我的webpack配置文件:
const webpack = requi
所以我最近读了一本关于反应技巧和技巧的书,上面写着
// Avoid: all the JSX written here will get compiled
// even though it is on the false branch
const Component1 = ({ isLoggedIn }) => {
return (
<>
{isLoggedIn && <div /*a lot of JSX */ />}
{!isLoggedIn && <div /*a lot of