The goal is to fail the build of the pipeline when the stryker scores lower than X. How it can be configured in the Jenkins file or some other approach?
The stryker conf:
config.set({
mutator: "javascript",
mutate: [...],
testRunner: "jest",
jest: {
projectType: "node",
config: require("jest.config.js"),
enableFindRelatedTests: true,
},
loglevel: "trace",
packageManager: "yarn",
reporters: ["html", "clear-text", "progress", "dashboard"],
transpilers: [],
coverageAnalysis: "off",
});
The piece of Jenkins file:
"Stryker test": {
stage('Mutation') {
node("${containerName}") {
container("${containerName}") {
unstash name: 'myApp'
dir("./my") {
sh '''hostname
./node_modules/.bin/stryker run
'''
}
You can achieve this using the
thresholds
configuration. For example, Stryker will error (exit-code 1) on scores below 40 with the following configuration:This means the result for your mutation score will be:
80
: Awesome! Reporters should color this green and happy.60
: Warning! Reporters should color this orange/yellow. Watch yourself! Nothing will break, however.60
: Danger! Reporters should color this in red. You're in danger, but still exit-code0
40
: Error! Stryker will exit with exit code 1, indicating a build failure. No consequence for reporters, though.