[英]How to run Jest tests with Node (express.js) backend and create-react-app as frontend
I have the following folder structure: 我具有以下文件夹结构:
Clearly React is using Jest in "Client" node_modules. 显然,React在“客户端” node_modules中使用Jest。 If i try to install Jest for server node_modules (one lvl up), i will get error from React, saying i have duplicate packages up in the tree.
如果我尝试为服务器的node_modules安装Jest(最多升级一个),我将从React收到错误消息,说我在树中有重复的软件包。 How should i run tests for server with Jest?
我应该如何使用Jest对服务器进行测试? How should i install Jest for server?
我应该如何为服务器安装Jest? Or should i?
还是我应该? Or i can use the same Jest react uses in "Client" folder?
或者我可以在“客户端”文件夹中使用相同的Jest react使用? If so, how?
如果是这样,怎么办? What is the command?
命令是什么? Really appreciate your help.
非常感谢您的帮助。
通过使用npm link client/node_modules/jest
来自项目root的npm link client/node_modules/jest
解决。
2 separate dependency trees, avoiding duplicate packages up in the tree
would look like following: 2个独立的依赖关系树,避免树中出现
duplicate packages up in the tree
如下所示:
server
├──> node_modules
├──> index.js
└──> package.json
client
├──> node_modules
├──> index.js
└──> package.json
.gitignore
README.md
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.