mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(test runner): show deep strack traces during imports (#20305)
Fixes #20239.
This commit is contained in:
parent
2c52d5be59
commit
b971dd3417
@ -38,8 +38,7 @@ type ParsedTsConfigData = {
|
|||||||
};
|
};
|
||||||
const cachedTSConfigs = new Map<string, ParsedTsConfigData | undefined>();
|
const cachedTSConfigs = new Map<string, ParsedTsConfigData | undefined>();
|
||||||
|
|
||||||
const kStackTraceLimit = 15;
|
Error.stackTraceLimit = 200;
|
||||||
Error.stackTraceLimit = kStackTraceLimit;
|
|
||||||
|
|
||||||
sourceMapSupport.install({
|
sourceMapSupport.install({
|
||||||
environment: 'node',
|
environment: 'node',
|
||||||
@ -270,11 +269,12 @@ export function wrapFunctionWithLocation<A extends any[], R>(func: (location: Lo
|
|||||||
column: frame.getColumnNumber(),
|
column: frame.getColumnNumber(),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
const oldStackTraceLimit = Error.stackTraceLimit;
|
||||||
Error.stackTraceLimit = 2;
|
Error.stackTraceLimit = 2;
|
||||||
const obj: { stack: Location } = {} as any;
|
const obj: { stack: Location } = {} as any;
|
||||||
Error.captureStackTrace(obj);
|
Error.captureStackTrace(obj);
|
||||||
const location = obj.stack;
|
const location = obj.stack;
|
||||||
Error.stackTraceLimit = kStackTraceLimit;
|
Error.stackTraceLimit = oldStackTraceLimit;
|
||||||
Error.prepareStackTrace = oldPrepareStackTrace;
|
Error.prepareStackTrace = oldPrepareStackTrace;
|
||||||
return func(location, ...args);
|
return func(location, ...args);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -32,6 +32,42 @@ test('should return the location of a syntax error', async ({ runInlineTest }) =
|
|||||||
expect(result.output).toContain('(6:18)');
|
expect(result.output).toContain('(6:18)');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should return the location of a syntax error with deep stack', async ({ runInlineTest }) => {
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'error.ts': `
|
||||||
|
const x = {
|
||||||
|
foo: 'bar';
|
||||||
|
};
|
||||||
|
`,
|
||||||
|
'qux.ts': `
|
||||||
|
import { error } from './error';
|
||||||
|
export function qux() { error() }
|
||||||
|
`,
|
||||||
|
'baz.ts': `
|
||||||
|
import { qux } from './qux';
|
||||||
|
export function baz() { qux() }
|
||||||
|
`,
|
||||||
|
'bar.ts': `
|
||||||
|
import { baz } from './baz';
|
||||||
|
export function bar() { baz() }
|
||||||
|
`,
|
||||||
|
'foo.ts': `
|
||||||
|
import { bar } from './bar';
|
||||||
|
export function foo() { bar() }
|
||||||
|
`,
|
||||||
|
'test.spec.ts': `
|
||||||
|
import { foo } from './foo';
|
||||||
|
foo();
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
expect(result.exitCode).toBe(1);
|
||||||
|
expect(result.output).toContain('qux.ts:4:7');
|
||||||
|
expect(result.output).toContain('baz.ts:4:7');
|
||||||
|
expect(result.output).toContain('bar.ts:4:7');
|
||||||
|
expect(result.output).toContain('foo.ts:4:7');
|
||||||
|
expect(result.output).toContain('test.spec.ts:5:7');
|
||||||
|
});
|
||||||
|
|
||||||
test('should print an improper error', async ({ runInlineTest }) => {
|
test('should print an improper error', async ({ runInlineTest }) => {
|
||||||
const result = await runInlineTest({
|
const result = await runInlineTest({
|
||||||
'error.spec.js': `
|
'error.spec.js': `
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user