remove attachment steps for everything except explicit testInfo.attach()

This commit is contained in:
Simon Knott 2024-10-16 09:00:00 +02:00
parent 71be4b982c
commit 606860d250
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -192,7 +192,7 @@ export class TestInfoImpl implements TestInfo {
this._attachmentsPush = this.attachments.push.bind(this.attachments); this._attachmentsPush = this.attachments.push.bind(this.attachments);
this.attachments.push = (...attachments: TestInfo['attachments']) => { this.attachments.push = (...attachments: TestInfo['attachments']) => {
for (const a of attachments) for (const a of attachments)
this._attach(a.name, a); this._attach(a);
return this.attachments.length; return this.attachments.length;
}; };
@ -398,14 +398,16 @@ export class TestInfoImpl implements TestInfo {
// ------------ TestInfo methods ------------ // ------------ TestInfo methods ------------
async attach(name: string, options: { path?: string, body?: string | Buffer, contentType?: string } = {}) { async attach(name: string, options: { path?: string, body?: string | Buffer, contentType?: string } = {}) {
this._attach(name, await normalizeAndSaveAttachment(this.outputPath(), name, options));
}
private _attach(name: string, attachment: TestInfo['attachments'][0]) {
const step = this._addStep({ const step = this._addStep({
title: `attach "${name}"`, title: `attach "${name}"`,
category: 'attach', category: 'attach',
}); });
const attachment = await normalizeAndSaveAttachment(this.outputPath(), name, options);
this._attach(attachment);
step.complete({ attachments: [attachment] });
}
private _attach(attachment: TestInfo['attachments'][0]) {
this._attachmentsPush(attachment); this._attachmentsPush(attachment);
this._onAttach({ this._onAttach({
testId: this.testId, testId: this.testId,
@ -414,7 +416,6 @@ export class TestInfoImpl implements TestInfo {
path: attachment.path, path: attachment.path,
body: attachment.body?.toString('base64') body: attachment.body?.toString('base64')
}); });
step.complete({ attachments: [attachment] });
} }
outputPath(...pathSegments: string[]){ outputPath(...pathSegments: string[]){