smoke - properly create screenshots and stop instances (#137220)

This commit is contained in:
Benjamin Pasero
2021-11-15 12:15:25 +01:00
committed by GitHub
parent c33965ab75
commit bacf6ed2c1
4 changed files with 26 additions and 24 deletions

View File

@@ -42,9 +42,9 @@ export function beforeSuite(opts: minimist.ParsedArgs, optionsTransform?: (opts:
});
}
export function afterSuite(opts: minimist.ParsedArgs) {
export function afterSuite(opts: minimist.ParsedArgs, appFn?: () => Application | undefined, joinFn?: () => Promise<unknown>) {
after(async function () {
const app = this.app as Application;
const app: Application = appFn?.() ?? this.app;
if (this.currentTest?.state === 'failed' && opts.screenshots) {
const name = this.currentTest!.fullTitle().replace(/[^a-z0-9\-]/ig, '_');
@@ -58,6 +58,10 @@ export function afterSuite(opts: minimist.ParsedArgs) {
if (app) {
await app.stop();
}
if (joinFn) {
await joinFn();
}
});
}