Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private readonly retrieveEarlyResult = (transpiledMutant: TranspiledMutant): MutantResult | null => {
if (transpiledMutant.transpileResult.error) {
if (this.log.isDebugEnabled()) {
this.log.debug(
`Transpile error occurred: "${transpiledMutant.transpileResult.error}" during transpiling of mutant ${transpiledMutant.mutant.toString()}`
);
}
const result = transpiledMutant.mutant.createResult(MutantStatus.TranspileError, []);
return result;
} else if (!transpiledMutant.mutant.runAllTests && !transpiledMutant.mutant.selectedTests.length) {
const result = transpiledMutant.mutant.createResult(MutantStatus.NoCoverage, []);
return result;
} else if (!transpiledMutant.changedAnyTranspiledFiles) {
const result = transpiledMutant.mutant.createResult(MutantStatus.Survived, []);
return result;
} else {
// No early result possible, need to run in the sandbox later
return null;
}
};
mutatorName: 'string',
originalLines: 'string',
range: [1, 2],
replacement: 'string',
sourceFilePath: 'string',
status: MutantStatus.TimedOut,
testsRan: ['']
};
const allReporter = new AllReporter();
allReporter.onMutantTested(result);
console.log(result);
console.log(
`Mutant status runtime error: ${MutantStatus[MutantStatus.RuntimeError]}`
);
console.log(
`Mutant status transpile error: ${MutantStatus[MutantStatus.TranspileError]}`
);
const matchedMutant: MatchedMutant = {
fileName: 'string',
id: '13',
mutatorName: '',
replacement: 'string',
scopedTestIds: [52],
timeSpentScopedTests: 52,
runAllTests: false,
};
allReporter.onAllMutantsMatchedWithTests([Object.freeze(matchedMutant)]);
const allMutants = Object.freeze([matchedMutant]);
allReporter.onAllMutantsMatchedWithTests(allMutants);
function getContextClassForStatus(status: MutantStatus) {
switch (status) {
case MutantStatus.Killed:
return 'success';
case MutantStatus.NoCoverage:
case MutantStatus.Survived:
return 'danger';
case MutantStatus.TimedOut:
return 'warning';
case MutantStatus.RuntimeError:
case MutantStatus.TranspileError:
return 'secondary';
}
}
private countNumbers(mutantResults: MutantResult[]) {
const count = (mutantResult: MutantStatus) => mutantResults.filter(_ => _.status === mutantResult).length;
const killed = count(MutantStatus.Killed);
const timedOut = count(MutantStatus.TimedOut);
const survived = count(MutantStatus.Survived);
const noCoverage = count(MutantStatus.NoCoverage);
const runtimeErrors = count(MutantStatus.RuntimeError);
const transpileErrors = count(MutantStatus.TranspileError);
const totalDetected = timedOut + killed;
const totalUndetected = survived + noCoverage;
const totalCovered = totalDetected + survived;
const totalValid = totalUndetected + totalDetected;
const totalInvalid = runtimeErrors + transpileErrors;
const totalMutants = totalValid + totalInvalid;
const mutationScore = totalValid > 0 ? (totalDetected / totalValid) * 100 : defaultScoreIfNoValidMutants;
const mutationScoreBasedOnCoveredCode = totalValid > 0 ? (totalDetected / totalCovered) * 100 || 0 : defaultScoreIfNoValidMutants;
return {
killed,
mutationScore,
mutationScoreBasedOnCoveredCode,
noCoverage,
runtimeErrors,
survived,
timedOut,
totalTests += result.testsRan.length;
}
switch (result.status) {
case MutantStatus.Killed:
this.log.debug(chalk.bold.green('Mutant killed!'));
this.logMutantResult(result, index, logDebugFn);
break;
case MutantStatus.TimedOut:
this.log.debug(chalk.bold.yellow('Mutant timed out!'));
this.logMutantResult(result, index, logDebugFn);
break;
case MutantStatus.RuntimeError:
this.log.debug(chalk.bold.yellow('Mutant caused a runtime error!'));
this.logMutantResult(result, index, logDebugFn);
break;
case MutantStatus.TranspileError:
this.log.debug(chalk.bold.yellow('Mutant caused a transpile error!'));
this.logMutantResult(result, index, logDebugFn);
break;
case MutantStatus.Survived:
this.logMutantResult(result, index, writeLineFn);
break;
case MutantStatus.NoCoverage:
this.logMutantResult(result, index, writeLineFn);
break;
}
});
this.writeLine(`Ran ${(totalTests / mutantResults.length).toFixed(2)} tests per mutant on average.`);
{MutantStatus[state]} {`(${filtered.length})`}
;
} else {
return '';
}
}
return <div class="row legend">
<form novalidate="novalidate" class="col-md-12">
{displayCheckbox(MutantStatus.NoCoverage, true)}
{displayCheckbox(MutantStatus.Survived, true)}
{displayCheckbox(MutantStatus.Killed, false)}
{displayCheckbox(MutantStatus.TimedOut, false)}
{displayCheckbox(MutantStatus.RuntimeError, false)}
{displayCheckbox(MutantStatus.TranspileError, false)}
<a class="stryker-collapse-expand-all" href="#">Expand all</a>
</form>
</div>;
}
private toStatus(status: MutantStatus): mutationTestReportSchema.MutantStatus {
switch (status) {
case MutantStatus.Killed:
return mutationTestReportSchema.MutantStatus.Killed;
case MutantStatus.NoCoverage:
return mutationTestReportSchema.MutantStatus.NoCoverage;
case MutantStatus.RuntimeError:
return mutationTestReportSchema.MutantStatus.RuntimeError;
case MutantStatus.Survived:
return mutationTestReportSchema.MutantStatus.Survived;
case MutantStatus.TimedOut:
return mutationTestReportSchema.MutantStatus.Timeout;
case MutantStatus.TranspileError:
return mutationTestReportSchema.MutantStatus.CompileError;
default:
this.logUnsupportedMutantStatus(status);
return mutationTestReportSchema.MutantStatus.RuntimeError;
}
}