Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public wrapUp() {
return new Promise(r => r());
}
}
const result: MutantResult = {
id: '13',
location: null,
mutatedLines: 'string',
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: '',
public onMutantTested(result: MutantResult) {
let toLog: string;
switch (result.status) {
case MutantStatus.Killed:
toLog = '.';
break;
case MutantStatus.TimedOut:
toLog = chalk.yellow('T');
break;
case MutantStatus.Survived:
toLog = chalk.bold.red('S');
break;
case MutantStatus.RuntimeError:
toLog = chalk.yellow('E');
break;
default:
toLog = '';
break;
}
process.stdout.write(toLog);
}
mutantResults.forEach((result, index) => {
if (result.testsRan) {
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);
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,
private determineMutantState(runResult: RunResult): MutantStatus {
switch (runResult.status) {
case RunStatus.Timeout:
return MutantStatus.TimedOut;
case RunStatus.Error:
return MutantStatus.RuntimeError;
case RunStatus.Complete:
if (runResult.tests.some(t => t.status === TestStatus.Failed)) {
return MutantStatus.Killed;
} else {
return MutantStatus.Survived;
}
}
}
<label class="form-check-label">
<input type="checkbox" value="{state.toString()}" checked="{isChecked}" class="form-check-input stryker-display">
{MutantStatus[state]} {`(${filtered.length})`}
</label>
;
} 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;
}
}
const adjustCurrentMutantResult = (valueToAdd: number) => (numberedMutant: { mutant: MutantResult, index: number }) => {
switch (numberedMutant.mutant.status) {
case MutantStatus.Killed:
currentCursorMutantStatuses.killed += valueToAdd;
break;
case MutantStatus.Survived:
currentCursorMutantStatuses.survived += valueToAdd;
break;
case MutantStatus.TimedOut:
currentCursorMutantStatuses.timeout += valueToAdd;
break;
case MutantStatus.NoCoverage:
currentCursorMutantStatuses.noCoverage += valueToAdd;
break;
}
};
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';
}
}