Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const testResult = factoryMethod(() => ({
name: 'name',
status: TestStatus.Success,
timeSpentMs: 10
}));
function completeResult(exitCode: number | null, timer: Timer): RunResult {
const duration = timer.elapsedMs();
if (exitCode === 0) {
return {
status: RunStatus.Complete,
tests: [
{
name: 'All tests',
status: TestStatus.Success,
timeSpentMs: duration
}
]
};
} else {
return {
status: RunStatus.Complete,
tests: [
{
failureMessages: [output.map(buf => buf.toString()).join(os.EOL)],
name: 'All tests',
status: TestStatus.Failed,
timeSpentMs: duration
}
]
};
public readonly onSpecComplete = (_browser: any, spec: KarmaSpec) => {
const name = spec.suite.reduce((name, suite) => name + suite + ' ', '') + spec.description;
let status = TestStatus.Failed;
if (spec.skipped) {
status = TestStatus.Skipped;
} else if (spec.success) {
status = TestStatus.Success;
}
const testResult: TestResult = {
failureMessages: spec.log,
name,
status,
timeSpentMs: spec.time
};
this.emit('test_result', testResult);
};
this.runner.on('pass', (test: any) => {
this.runResult.tests.push({
name: test.fullTitle(),
status: TestStatus.Success,
timeSpentMs: this.timer.elapsedMs()
});
this.passedCount++;
this.timer.reset();
});
private determineTestResultStatus(status: string) {
switch (status) {
case 'passed':
return TestStatus.Success;
case 'pending':
return TestStatus.Skipped;
case 'todo':
return TestStatus.Skipped;
default:
return TestStatus.Failed;
}
}
}
private toTestResultStatus(state: CompletedState): TestStatus {
switch (state) {
case 'failing':
return TestStatus.Failed;
case 'passing':
return TestStatus.Success;
default:
return TestStatus.Skipped;
}
}
}
export function toStrykerTestResult(specResult: jasmine.CustomReporterResult, timeSpentMs: number): TestResult {
let status = TestStatus.Failed;
let failureMessages: string[] | undefined;
if (specResult.status === 'disabled' || specResult.status === 'pending' || specResult.status === 'excluded') {
status = TestStatus.Skipped;
} else if (!specResult.failedExpectations || specResult.failedExpectations.length === 0) {
status = TestStatus.Success;
} else {
failureMessages = specResult.failedExpectations.map(failedExpectation => failedExpectation.message);
}
return {
failureMessages,
name: specResult.fullName,
status,
timeSpentMs
};
}