[英]Setup jest multi projects with create-react-app and node
My projects uses a /server
folder for my backend code and /react-ui
for my client side code.我的项目使用
/server
文件夹作为我的后端代码和/react-ui
作为我的客户端代码。 There's a package.json
in each folder.每个文件夹中有一个
package.json
。 I can run test separately in the cmd line, but I would like to run both at the same time.我可以在 cmd 行中单独运行测试,但我想同时运行两者。 I know about the multi projects feature of jest, but it doesn't seem to work with create-react-app.
我知道 jest 的多项目功能,但它似乎不适用于 create-react-app。 I'm trying to setup jest with babel as if I was not using create-react-app, but it seems like the wrong approach considering jest is already setup in CRA.
我正在尝试使用 babel 设置 jest,就好像我没有使用 create-react-app 一样,但考虑到 jest 已经在 CRA 中设置,这似乎是错误的方法。
My current setup runs from the /server
jest installation.我当前的设置从
/server
jest 安装运行。 With projects: ['<rootDir>', '<rootDir>/../react-ui']
.对于
projects: ['<rootDir>', '<rootDir>/../react-ui']
。 The jest documentation isn't clear how I could direct it to run npm test
in /react-ui
开玩笑的文档不清楚我如何指导它在
/react-ui
运行npm test
My only goal is to be able to watch both at the same time and I would like to not eject from CRA.我唯一的目标是能够同时观看两者,我不想从 CRA 退出。
您可以在主级别上使用 (gulp) 脚本来分别运行每个测试,但使用相同的配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.