Update stale screenshots playwright reporter
At some point it seems that playwright changed how reporters are passed flakes. https://github.com/microsoft/playwright/pull/39145 needs to land to fully fix the reporter though
This commit is contained in:
committed by
GitHub
parent
30cbbd48b3
commit
a9e76dbb8a
@@ -25,7 +25,7 @@ export const ANNOTATION = "_screenshot";
|
|||||||
class StaleScreenshotReporter implements Reporter {
|
class StaleScreenshotReporter implements Reporter {
|
||||||
private readonly snapshotRoots = new Set<string>();
|
private readonly snapshotRoots = new Set<string>();
|
||||||
private readonly screenshots = new Set<string>();
|
private readonly screenshots = new Set<string>();
|
||||||
private failing = false;
|
private readonly failing = new Set<string>();
|
||||||
private success = true;
|
private success = true;
|
||||||
|
|
||||||
public onBegin(config: FullConfig): void {
|
public onBegin(config: FullConfig): void {
|
||||||
@@ -36,8 +36,11 @@ class StaleScreenshotReporter implements Reporter {
|
|||||||
|
|
||||||
public onTestEnd(test: TestCase): void {
|
public onTestEnd(test: TestCase): void {
|
||||||
if (!test.ok()) {
|
if (!test.ok()) {
|
||||||
this.failing = true;
|
this.failing.add(test.id);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
this.failing.delete(test.id); // delete if passed on re-run
|
||||||
|
|
||||||
for (const annotation of test.annotations) {
|
for (const annotation of test.annotations) {
|
||||||
if (annotation.type === ANNOTATION && annotation.description) {
|
if (annotation.type === ANNOTATION && annotation.description) {
|
||||||
this.screenshots.add(annotation.description);
|
this.screenshots.add(annotation.description);
|
||||||
@@ -54,7 +57,10 @@ class StaleScreenshotReporter implements Reporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async onExit(): Promise<void> {
|
public async onExit(): Promise<void> {
|
||||||
if (this.failing) return;
|
if (this.failing.size) {
|
||||||
|
console.error(`${this.failing.size} tests failed, skipping stale screenshot reporter.`);
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.snapshotRoots.size) {
|
if (!this.snapshotRoots.size) {
|
||||||
this.error("No snapshot directories found, did you set the snapshotDir in your Playwright config?", "");
|
this.error("No snapshot directories found, did you set the snapshotDir in your Playwright config?", "");
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user