test(core): update ErrorHandler tests to handle browsers without stack (#11141)
Fixes #11114
This commit is contained in:
parent
af63378fa0
commit
7dee1ee4cf
|
@ -48,8 +48,10 @@ export function main() {
|
||||||
it('should output stackTrace', () => {
|
it('should output stackTrace', () => {
|
||||||
var error = new Error('message!');
|
var error = new Error('message!');
|
||||||
var stack = getStack(error);
|
var stack = getStack(error);
|
||||||
|
if (stack) {
|
||||||
var e = errorToString(error);
|
var e = errorToString(error);
|
||||||
expect(e).toContain(stack);
|
expect(e).toContain(stack);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('context', () => {
|
describe('context', () => {
|
||||||
|
@ -62,11 +64,16 @@ export function main() {
|
||||||
} as any as DebugContext;
|
} as any as DebugContext;
|
||||||
var original = new ViewWrappedError(cause, context);
|
var original = new ViewWrappedError(cause, context);
|
||||||
var e = errorToString(new WrappedError('message', original));
|
var e = errorToString(new WrappedError('message', original));
|
||||||
expect(e).toEqual(`EXCEPTION: message caused by: Error in context! caused by: message!
|
expect(e).toEqual(
|
||||||
|
stack ? `EXCEPTION: message caused by: Error in context! caused by: message!
|
||||||
ORIGINAL EXCEPTION: message!
|
ORIGINAL EXCEPTION: message!
|
||||||
ORIGINAL STACKTRACE:
|
ORIGINAL STACKTRACE:
|
||||||
${stack}
|
${stack}
|
||||||
ERROR CONTEXT:
|
ERROR CONTEXT:
|
||||||
|
Context` :
|
||||||
|
`EXCEPTION: message caused by: Error in context! caused by: message!
|
||||||
|
ORIGINAL EXCEPTION: message!
|
||||||
|
ERROR CONTEXT:
|
||||||
Context`);
|
Context`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -74,10 +81,9 @@ Context`);
|
||||||
describe('original exception', () => {
|
describe('original exception', () => {
|
||||||
it('should print original exception message if available (original is Error)', () => {
|
it('should print original exception message if available (original is Error)', () => {
|
||||||
var realOriginal = new Error('inner');
|
var realOriginal = new Error('inner');
|
||||||
var stack = getStack(realOriginal);
|
|
||||||
var original = new WrappedError('wrapped', realOriginal);
|
var original = new WrappedError('wrapped', realOriginal);
|
||||||
var e = errorToString(new WrappedError('wrappedwrapped', original));
|
var e = errorToString(new WrappedError('wrappedwrapped', original));
|
||||||
expect(e).toContain(stack);
|
expect(e).toContain('inner');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should print original exception message if available (original is not Error)', () => {
|
it('should print original exception message if available (original is not Error)', () => {
|
||||||
|
@ -92,9 +98,11 @@ Context`);
|
||||||
it('should print original stack if available', () => {
|
it('should print original stack if available', () => {
|
||||||
var realOriginal = new Error('inner');
|
var realOriginal = new Error('inner');
|
||||||
var stack = getStack(realOriginal);
|
var stack = getStack(realOriginal);
|
||||||
|
if (stack) {
|
||||||
var original = new WrappedError('wrapped', realOriginal);
|
var original = new WrappedError('wrapped', realOriginal);
|
||||||
var e = errorToString(new WrappedError('wrappedwrapped', original));
|
var e = errorToString(new WrappedError('wrappedwrapped', original));
|
||||||
expect(e).toContain(stack);
|
expect(e).toContain(stack);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue