目前,我的工作流程是先运行npm test
,再运行npm build
。
有没有一种方法可以将test命令集成到build命令中,以便每次构建时都自动运行测试?
package.json:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
答案 0 :(得分:2)
您在这里找到解决方法
"scripts": {
"start": "react-scripts start",
"build": "react-scripts test && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
您可以使用&&运算符将两个步骤合并为一个步骤。每次您首先运行npm build
时,它将运行测试用例,然后进行构建