revert reporters
This commit is contained in:
parent
3c9895588a
commit
896ea2dd67
|
|
@ -14,7 +14,7 @@
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { ErrorDetails, TestAttachment, TestCase, TestResult, TestStep } from './types';
|
import type { TestAttachment, TestCase, TestResult, TestStep } from './types';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { TreeItem } from './treeItem';
|
import { TreeItem } from './treeItem';
|
||||||
import { msToString } from './utils';
|
import { msToString } from './utils';
|
||||||
|
|
@ -150,30 +150,26 @@ export const TestResultView: React.FC<{
|
||||||
</div>;
|
</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
function classifyErrors(testErrors: ErrorDetails[], diffs: ImageDiff[]) {
|
function classifyErrors(testErrors: string[], diffs: ImageDiff[]) {
|
||||||
return testErrors.map(error => {
|
return testErrors.map(error => {
|
||||||
if (error.shortMessage?.includes('Screenshot comparison failed:') && error.actual && error.expected) {
|
if (error.includes('Screenshot comparison failed:')) {
|
||||||
const matchingDiff = diffs.find(diff => {
|
const matchingDiff = diffs.find(diff => {
|
||||||
const attachmentName = diff.actual?.attachment.name;
|
const attachmentName = diff.actual?.attachment.name;
|
||||||
return attachmentName && error.actual.endsWith(attachmentName);
|
return attachmentName && error.includes(attachmentName);
|
||||||
});
|
});
|
||||||
const errorSuffix = ['Call log:',
|
|
||||||
...(error.log?.map(line => ' - ' + line) || []),
|
|
||||||
'',
|
|
||||||
error.snippet,
|
|
||||||
'',
|
|
||||||
error.callStack,
|
|
||||||
].join('\n');
|
|
||||||
if (matchingDiff) {
|
if (matchingDiff) {
|
||||||
return {
|
const lines = error.split('\n');
|
||||||
type: 'screenshot',
|
const index = lines.findIndex(line => /Expected:|Previous:|Received:/.test(line));
|
||||||
diff: matchingDiff,
|
const errorPrefix = index !== -1 ? lines.slice(0, index).join('\n') : lines[0];
|
||||||
errorPrefix: error.shortMessage,
|
|
||||||
errorSuffix
|
const diffIndex = lines.findIndex(line => / +Diff:/.test(line));
|
||||||
};
|
const errorSuffix = diffIndex !== -1 ? lines.slice(diffIndex + 2).join('\n') : lines.slice(1).join('\n');
|
||||||
|
|
||||||
|
return { type: 'screenshot', diff: matchingDiff, errorPrefix, errorSuffix };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { type: 'regular', error: error.message };
|
return { type: 'regular', error };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,17 +83,6 @@ export type TestCase = Omit<TestCaseSummary, 'results'> & {
|
||||||
results: TestResult[];
|
results: TestResult[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ErrorDetails = {
|
|
||||||
message: string;
|
|
||||||
location?: Location;
|
|
||||||
shortMessage?: string;
|
|
||||||
log?: string[];
|
|
||||||
expected?: any;
|
|
||||||
actual?: any;
|
|
||||||
snippet?: string;
|
|
||||||
callStack?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type TestAttachment = {
|
export type TestAttachment = {
|
||||||
name: string;
|
name: string;
|
||||||
body?: string;
|
body?: string;
|
||||||
|
|
@ -106,7 +95,7 @@ export type TestResult = {
|
||||||
startTime: string;
|
startTime: string;
|
||||||
duration: number;
|
duration: number;
|
||||||
steps: TestStep[];
|
steps: TestStep[];
|
||||||
errors: ErrorDetails[];
|
errors: string[];
|
||||||
attachments: TestAttachment[];
|
attachments: TestAttachment[];
|
||||||
status: 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted';
|
status: 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -32,17 +32,6 @@ type Annotation = {
|
||||||
type ErrorDetails = {
|
type ErrorDetails = {
|
||||||
message: string;
|
message: string;
|
||||||
location?: Location;
|
location?: Location;
|
||||||
callStack?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type TestResultErrorDetails = ErrorDetails & {
|
|
||||||
shortMessage?: string;
|
|
||||||
log?: string[];
|
|
||||||
expected?: any;
|
|
||||||
actual?: any;
|
|
||||||
|
|
||||||
snippet?: string;
|
|
||||||
stack?: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type TestSummary = {
|
type TestSummary = {
|
||||||
|
|
@ -375,8 +364,8 @@ function quotePathIfNeeded(path: string): string {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatResultFailure(test: TestCase, result: TestResult, initialIndent: string, highlightCode: boolean): TestResultErrorDetails[] {
|
export function formatResultFailure(test: TestCase, result: TestResult, initialIndent: string, highlightCode: boolean): ErrorDetails[] {
|
||||||
const errorDetails: TestResultErrorDetails[] = [];
|
const errorDetails: ErrorDetails[] = [];
|
||||||
|
|
||||||
if (result.status === 'passed' && test.expectedStatus === 'failed') {
|
if (result.status === 'passed' && test.expectedStatus === 'failed') {
|
||||||
errorDetails.push({
|
errorDetails.push({
|
||||||
|
|
@ -394,12 +383,6 @@ export function formatResultFailure(test: TestCase, result: TestResult, initialI
|
||||||
errorDetails.push({
|
errorDetails.push({
|
||||||
message: indent(formattedError.message, initialIndent),
|
message: indent(formattedError.message, initialIndent),
|
||||||
location: formattedError.location,
|
location: formattedError.location,
|
||||||
shortMessage: error.shortMessage,
|
|
||||||
log: error.log,
|
|
||||||
expected: error.expected,
|
|
||||||
actual: error.actual,
|
|
||||||
snippet: error.snippet,
|
|
||||||
callStack: formattedError.callStack,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return errorDetails;
|
return errorDetails;
|
||||||
|
|
@ -479,12 +462,9 @@ export function formatError(error: TestError, highlightCode: boolean): ErrorDeta
|
||||||
tokens.push(snippet);
|
tokens.push(snippet);
|
||||||
}
|
}
|
||||||
|
|
||||||
let callStack;
|
|
||||||
if (parsedStack && parsedStack.stackLines.length) {
|
if (parsedStack && parsedStack.stackLines.length) {
|
||||||
tokens.push('');
|
tokens.push('');
|
||||||
tokens.push(colors.dim(parsedStack.stackLines.join('\n')));
|
tokens.push(colors.dim(parsedStack.stackLines.join('\n')));
|
||||||
// TODO: pass raw lines.
|
|
||||||
callStack = colors.dim(parsedStack.stackLines.join('\n'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let location = error.location;
|
let location = error.location;
|
||||||
|
|
@ -494,7 +474,6 @@ export function formatError(error: TestError, highlightCode: boolean): ErrorDeta
|
||||||
return {
|
return {
|
||||||
location,
|
location,
|
||||||
message: tokens.join('\n'),
|
message: tokens.join('\n'),
|
||||||
callStack,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -485,7 +485,7 @@ class HtmlBuilder {
|
||||||
startTime: result.startTime.toISOString(),
|
startTime: result.startTime.toISOString(),
|
||||||
retry: result.retry,
|
retry: result.retry,
|
||||||
steps: dedupeSteps(result.steps).map(s => this._createTestStep(s)),
|
steps: dedupeSteps(result.steps).map(s => this._createTestStep(s)),
|
||||||
errors: formatResultFailure(test, result, '', true),
|
errors: formatResultFailure(test, result, '', true).map(error => error.message),
|
||||||
status: result.status,
|
status: result.status,
|
||||||
attachments: this._serializeAttachments([
|
attachments: this._serializeAttachments([
|
||||||
...result.attachments,
|
...result.attachments,
|
||||||
|
|
|
||||||
|
|
@ -222,8 +222,7 @@ class JSONReporter implements ReporterV2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _serializeError(error: TestError): JSONReportError {
|
private _serializeError(error: TestError): JSONReportError {
|
||||||
const { message, location } = formatError(error, true);
|
return formatError(error, true);
|
||||||
return { message, location };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private _serializeTestStep(step: TestStep): JSONReportTestStep {
|
private _serializeTestStep(step: TestStep): JSONReportTestStep {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue