gpt4 book ai didi

node.js - 如何使用 Node (express.js) 后端和 create-react-app 作为前端运行 Jest 测试

转载 作者:太空宇宙 更新时间:2023-11-03 23:15:44 27 4
gpt4 key购买 nike

我有以下文件夹结构:

enter image description here

显然 React 在“客户端”node_modules 中使用 Jest。如果我尝试为服务器node_modules(向上一级)安装Jest,我会从React中得到错误,说我在树中存在重复的包。我应该如何使用 Jest 运行服务器测试?我应该如何为服务器安装 Jest?或者我应该?或者我可以在“Client”文件夹中使用相同的 Jest React?如果是这样,怎么办?命令是什么?非常感谢您的帮助。

最佳答案

2 个独立的依赖树,避免树中出现重复的包,如下所示:

server
├──> node_modules
├──> index.js
└──> package.json
client
├──> node_modules
├──> index.js
└──> package.json
.gitignore
README.md

关于node.js - 如何使用 Node (express.js) 后端和 create-react-app 作为前端运行 Jest 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55748085/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com