如何 运行 即使 React 测试用例失败也能完全构建 azure devops
How to run the azure devops build completely even with failing react test cases
如何 运行 azure devops 完全构建,即使有一些失败的测试用例。使用下面提到的脚本,构建正在退出,错误代码为 1。
azure 构建流水线任务:
- script: "yarn --cwd frontend/ coverage"
enabled: true
displayName: "Run React Code coverage"
Package.json
"test": "react-scripts test --env=jest-environment-jsdom-sixteen",
"coverage": "react-scripts test --coverage --watchAll --env=jest-environment-jsdom-sixteen",
您可以将 continueOnError: true
添加到脚本步骤以忽略其失败。
来自the docs:
steps:
- script: string # contents of the script to run
displayName: string # friendly name displayed in the UI
name: string # identifier for this step (A-Z, a-z, 0-9, and underscore)
workingDirectory: string # initial working directory for the step
failOnStderr: boolean # if the script writes to stderr, should that be treated as the step failing?
condition: string
continueOnError: boolean # 'true' if future steps should run even if this step fails; defaults to 'false'
enabled: boolean # whether to run this step; defaults to 'true'
target:
container: string # where this step will run; values are the container name or the word 'host'
commands: enum # whether to process all logging commands from this step; values are `any` (default) or `restricted`
timeoutInMinutes: number
env: { string: string } # list of environment variables to add
PS:忽略 CI 中的测试失败是个坏主意。是什么阻止您解决问题,而不是忽略它们?
如何 运行 azure devops 完全构建,即使有一些失败的测试用例。使用下面提到的脚本,构建正在退出,错误代码为 1。
azure 构建流水线任务:
- script: "yarn --cwd frontend/ coverage"
enabled: true
displayName: "Run React Code coverage"
Package.json
"test": "react-scripts test --env=jest-environment-jsdom-sixteen",
"coverage": "react-scripts test --coverage --watchAll --env=jest-environment-jsdom-sixteen",
您可以将 continueOnError: true
添加到脚本步骤以忽略其失败。
来自the docs:
steps:
- script: string # contents of the script to run
displayName: string # friendly name displayed in the UI
name: string # identifier for this step (A-Z, a-z, 0-9, and underscore)
workingDirectory: string # initial working directory for the step
failOnStderr: boolean # if the script writes to stderr, should that be treated as the step failing?
condition: string
continueOnError: boolean # 'true' if future steps should run even if this step fails; defaults to 'false'
enabled: boolean # whether to run this step; defaults to 'true'
target:
container: string # where this step will run; values are the container name or the word 'host'
commands: enum # whether to process all logging commands from this step; values are `any` (default) or `restricted`
timeoutInMinutes: number
env: { string: string } # list of environment variables to add
PS:忽略 CI 中的测试失败是个坏主意。是什么阻止您解决问题,而不是忽略它们?