don't wrap in error
This commit is contained in:
parent
e4b1dc95dc
commit
314a67fa73
|
|
@ -289,8 +289,7 @@ class ExpectMetaInfoProxyHandler implements ProxyHandler<any> {
|
||||||
|
|
||||||
const step = testInfo._addStep(stepInfo);
|
const step = testInfo._addStep(stepInfo);
|
||||||
|
|
||||||
const reportStepError = (unknownError: unknown) => {
|
const reportStepError = (jestError: Error | unknown) => {
|
||||||
const jestError = unknownError instanceof Error ? unknownError : new Error(String(unknownError));
|
|
||||||
const error = isExpectError(jestError) ? new ExpectError(jestError, customMessage, stackFrames) : jestError;
|
const error = isExpectError(jestError) ? new ExpectError(jestError, customMessage, stackFrames) : jestError;
|
||||||
step.complete({ error });
|
step.complete({ error });
|
||||||
if (this._info.isSoft)
|
if (this._info.isSoft)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import type { Attachment } from './testTracing';
|
||||||
import type { StackFrame } from '@protocol/channels';
|
import type { StackFrame } from '@protocol/channels';
|
||||||
|
|
||||||
export interface TestStepInternal {
|
export interface TestStepInternal {
|
||||||
complete(result: { error?: Error, attachments?: Attachment[] }): void;
|
complete(result: { error?: Error | unknown, attachments?: Attachment[] }): void;
|
||||||
stepId: string;
|
stepId: string;
|
||||||
title: string;
|
title: string;
|
||||||
category: 'hook' | 'fixture' | 'test.step' | 'expect' | 'attach' | string;
|
category: 'hook' | 'fixture' | 'test.step' | 'expect' | 'attach' | string;
|
||||||
|
|
@ -267,7 +267,7 @@ export class TestInfoImpl implements TestInfo {
|
||||||
|
|
||||||
step.endWallTime = Date.now();
|
step.endWallTime = Date.now();
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
if (!(result.error as any)[stepSymbol])
|
if (typeof result.error === 'object' && !(result.error as any)?.[stepSymbol])
|
||||||
(result.error as any)[stepSymbol] = step;
|
(result.error as any)[stepSymbol] = step;
|
||||||
const error = serializeError(result.error);
|
const error = serializeError(result.error);
|
||||||
if (data.boxedStack)
|
if (data.boxedStack)
|
||||||
|
|
@ -324,13 +324,13 @@ export class TestInfoImpl implements TestInfo {
|
||||||
this.status = 'interrupted';
|
this.status = 'interrupted';
|
||||||
}
|
}
|
||||||
|
|
||||||
_failWithError(error: Error) {
|
_failWithError(error: Error | unknown) {
|
||||||
if (this.status === 'passed' || this.status === 'skipped')
|
if (this.status === 'passed' || this.status === 'skipped')
|
||||||
this.status = error instanceof TimeoutManagerError ? 'timedOut' : 'failed';
|
this.status = error instanceof TimeoutManagerError ? 'timedOut' : 'failed';
|
||||||
const serialized = serializeError(error);
|
const serialized = serializeError(error);
|
||||||
const step = (error as any)[stepSymbol] as TestStepInternal | undefined;
|
const step: TestStepInternal | undefined = typeof error === 'object' ? (error as any)?.[stepSymbol] : undefined;
|
||||||
if (step && step.boxedStack)
|
if (step && step.boxedStack)
|
||||||
serialized.stack = `${error.name}: ${error.message}\n${stringifyStackFrames(step.boxedStack).join('\n')}`;
|
serialized.stack = `${(error as Error).name}: ${(error as Error).message}\n${stringifyStackFrames(step.boxedStack).join('\n')}`;
|
||||||
this.errors.push(serialized);
|
this.errors.push(serialized);
|
||||||
this._tracing.appendForError(serialized);
|
this._tracing.appendForError(serialized);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -243,5 +243,5 @@ test('should propagate promise rejections', { annotation: { type: 'issue', descr
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result.output).toContain('Error: some error');
|
expect(result.output).toContain('some error');
|
||||||
});
|
});
|
||||||
Loading…
Reference in a new issue