mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 01:29:04 +01:00
Playwright: record a trace per failing test, not suite (#138600)
* smoke - record traces per test and not entire suite
* smoke - only persist failing tests
* smoke - cleanup
* smoke - more logging
* smoke - push a test failure to proof the point
* smoke - switch back to chrome for smoke tests
* smoke - warn when exit takes 10s
* Revert "smoke - push a test failure to proof the point"
This reverts commit e572a0c40d.
This commit is contained in:
@@ -19,13 +19,16 @@ export function itRepeat(n: number, description: string, callback: (this: Contex
|
||||
}
|
||||
}
|
||||
|
||||
export function beforeSuite(args: minimist.ParsedArgs, optionsTransform?: (opts: ApplicationOptions) => Promise<ApplicationOptions>) {
|
||||
export function installCommonTestHandlers(args: minimist.ParsedArgs, optionsTransform?: (opts: ApplicationOptions) => Promise<ApplicationOptions>) {
|
||||
installCommonBeforeHandlers(args, optionsTransform);
|
||||
installCommonAfterHandlers(args);
|
||||
}
|
||||
|
||||
export function installCommonBeforeHandlers(args: minimist.ParsedArgs, optionsTransform?: (opts: ApplicationOptions) => Promise<ApplicationOptions>) {
|
||||
before(async function () {
|
||||
const testTitle = this.currentTest?.title;
|
||||
const suiteTitle = this.currentTest?.parent?.title;
|
||||
|
||||
this.app = await startApp(args, this.defaultOptions, async opts => {
|
||||
opts.suiteTitle = suiteTitle;
|
||||
opts.testTitle = testTitle;
|
||||
|
||||
if (optionsTransform) {
|
||||
@@ -35,6 +38,12 @@ export function beforeSuite(args: minimist.ParsedArgs, optionsTransform?: (opts:
|
||||
return opts;
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
if (this.app) {
|
||||
await this.app.startTracing(this.currentTest?.title);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function startApp(args: minimist.ParsedArgs, options: ApplicationOptions, optionsTransform?: (opts: ApplicationOptions) => Promise<ApplicationOptions>): Promise<Application> {
|
||||
@@ -66,7 +75,7 @@ export function getRandomUserDataDir(options: ApplicationOptions): string {
|
||||
return options.userDataDir.concat(`-${userDataPathSuffix}`);
|
||||
}
|
||||
|
||||
export function afterSuite(opts: minimist.ParsedArgs, appFn?: () => Application | undefined, joinFn?: () => Promise<unknown>) {
|
||||
export function installCommonAfterHandlers(opts: minimist.ParsedArgs, appFn?: () => Application | undefined, joinFn?: () => Promise<unknown>) {
|
||||
after(async function () {
|
||||
const app: Application = appFn?.() ?? this.app;
|
||||
|
||||
@@ -87,6 +96,12 @@ export function afterSuite(opts: minimist.ParsedArgs, appFn?: () => Application
|
||||
await joinFn();
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
if (this.app) {
|
||||
await this.app.stopTracing(this.currentTest?.title, this.currentTest?.state === 'failed');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function timeout(i: number) {
|
||||
|
||||
Reference in New Issue
Block a user