我的 package.json 文件是
"scripts": {
"start": "concurrently \"nodemon index.js\" \"PORT=3000 react-scripts start\"",
"build": "react-scripts build",
"server": "NODE_ENV=production nodemon index.js",
"dev": "NODE_ENV=development nodemon index.js",
"test": "react-scripts test",
"eslint": "eslint .",
"cypress:open": "cypress open",
"start:test": "NODE_ENV=test concurrently \"NODE_ENV=test nodemon index.js\" \"NODE_ENV=test PORT=3000 react-scripts start\""
},
我在节点 app.js 中创建的路由器是
if (process.env.NODE_ENV === 'test') {
const testingRouter = require('./controllers/testing')
app.use('/api/testing', testingRouter)
}
但是当我运行 cypress test 它抱怨没有这样的路由器。如何在调用 npm run cypress:open 命令时制作 NODE_ENV=test?
以及如何通过 console.log(process.env.NODE_ENV) 查看是否将其传递给 cypres 进程?