每次我们尝试运行 Jest 单元测试时,我们都必须运行 npm test。当我构建应用程序时(在 npm start 或 npm build 时),有什么方法可以运行这些测试
最佳答案
您可以在 package.json 中组合多个步骤,如下所示:
"scripts": {
"start": "sh start.sh",
"test": "sh test.sh",
"test_start": "npm test && npm start"
}
运行测试时,只需运行
npm run test_start
这将确保您的测试在运行开始之前成功。
希望这有帮助!
关于javascript - 我们如何与 npm start 或 npm build 一起运行 jest 单元测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52755471/