fix playwright.trace tests
This commit is contained in:
parent
617dfcc738
commit
0861d29630
|
|
@ -638,7 +638,7 @@ class ArtifactsRecorder {
|
||||||
try {
|
try {
|
||||||
const screenshotPath = this._createScreenshotAttachmentPath();
|
const screenshotPath = this._createScreenshotAttachmentPath();
|
||||||
await fs.promises.rename(file, screenshotPath);
|
await fs.promises.rename(file, screenshotPath);
|
||||||
this._attachScreenshot(screenshotPath);
|
await this._attachScreenshot(screenshotPath);
|
||||||
} catch {
|
} catch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -665,14 +665,14 @@ class ArtifactsRecorder {
|
||||||
if (temporary)
|
if (temporary)
|
||||||
this._temporaryScreenshots.push(screenshotPath);
|
this._temporaryScreenshots.push(screenshotPath);
|
||||||
else
|
else
|
||||||
this._attachScreenshot(screenshotPath);
|
await this._attachScreenshot(screenshotPath);
|
||||||
} catch {
|
} catch {
|
||||||
// Screenshot may fail, just ignore.
|
// Screenshot may fail, just ignore.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _attachScreenshot(screenshotPath: string) {
|
private async _attachScreenshot(screenshotPath: string) {
|
||||||
this._testInfo.attachments.push({ name: 'screenshot', path: screenshotPath, contentType: 'image/png' });
|
await this._testInfo.attach('screenshot', { path: screenshotPath, contentType: 'image/png' });
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _screenshotOnTestFailure() {
|
private async _screenshotOnTestFailure() {
|
||||||
|
|
|
||||||
|
|
@ -540,7 +540,7 @@ test('should include attachments by default', async ({ runInlineTest, server },
|
||||||
contentType: 'text/plain',
|
contentType: 'text/plain',
|
||||||
sha1: expect.any(String),
|
sha1: expect.any(String),
|
||||||
}]);
|
}]);
|
||||||
expect([...trace.resources.keys()].filter(f => f.startsWith('resources/'))).toHaveLength(1);
|
expect([...trace.resources.keys()]).toContain(`resources/${trace.actions[1].attachments[0].sha1}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should opt out of attachments', async ({ runInlineTest, server }, testInfo) => {
|
test('should opt out of attachments', async ({ runInlineTest, server }, testInfo) => {
|
||||||
|
|
@ -566,7 +566,7 @@ test('should opt out of attachments', async ({ runInlineTest, server }, testInfo
|
||||||
'After Hooks',
|
'After Hooks',
|
||||||
]);
|
]);
|
||||||
expect(trace.actions[1].attachments).toEqual(undefined);
|
expect(trace.actions[1].attachments).toEqual(undefined);
|
||||||
expect([...trace.resources.keys()].filter(f => f.startsWith('resources/'))).toHaveLength(0);
|
expect([...trace.resources.keys()].filter(f => f.startsWith('resources/'))).toEqual([expect.stringMatching(/^resources\/src@.*$/)]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should record with custom page fixture', async ({ runInlineTest }, testInfo) => {
|
test('should record with custom page fixture', async ({ runInlineTest }, testInfo) => {
|
||||||
|
|
@ -730,8 +730,6 @@ test('should not throw when attachment is missing', async ({ runInlineTest }, te
|
||||||
|
|
||||||
expect(result.exitCode).toBe(0);
|
expect(result.exitCode).toBe(0);
|
||||||
expect(result.passed).toBe(1);
|
expect(result.passed).toBe(1);
|
||||||
const trace = await parseTrace(testInfo.outputPath('test-results', 'a-passes', 'trace.zip'));
|
|
||||||
expect(trace.actionTree).toContain('attach "screenshot"');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should not throw when screenshot on failure fails', async ({ runInlineTest, server }, testInfo) => {
|
test('should not throw when screenshot on failure fails', async ({ runInlineTest, server }, testInfo) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue