【问题标题】:How to make the test suite run before each build?如何在每次构建之前运行测试套件?
【发布时间】:2020-09-08 14:40:01
【问题描述】:

目前我的工作流程是先运行npm test,然后再运行npm build

有没有办法将测试命令集成到构建命令中,以便每次构建时自动运行测试?

package.json:

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
},

【问题讨论】:

    标签: node.js reactjs npm react-scripts


    【解决方案1】:

    给你一个解决方案

    "scripts": {
      "start": "react-scripts start",
      "build": "react-scripts test && react-scripts build",
      "test": "react-scripts test",
      "eject": "react-scripts eject"
    }
    

    您可以使用 && 运算符将两个步骤合二为一。每次您首先运行npm build 时,它都会运行测试用例,然后进行构建

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-12
      • 2014-09-20
      • 1970-01-01
      • 1970-01-01
      • 2017-10-07
      • 2014-11-24
      相关资源
      最近更新 更多