简体   繁体   中英

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. 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. How should i run tests for server with Jest? How should i install Jest for server? Or should i? Or i can use the same Jest react uses in "Client" folder? 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM