mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-04 19:56:45 +02:00
Reuse annotation var
This commit is contained in:
parent
78bc53ef0a
commit
75cf1ee738
@ -19,6 +19,8 @@ import {
|
||||
import { sanitizeForFilePath } from "playwright-core/lib/utils";
|
||||
import { extname } from "node:path";
|
||||
|
||||
import { ANNOTATION } from "../stale-screenshot-reporter.js";
|
||||
|
||||
// Based on https://github.com/microsoft/playwright/blob/2b77ed4d7aafa85a600caa0b0d101b72c8437eeb/packages/playwright/src/util.ts#L206C8-L210C2
|
||||
function sanitizeFilePathBeforeExtension(filePath: string): string {
|
||||
const ext = extname(filePath);
|
||||
@ -68,8 +70,7 @@ export const expect = baseExpect.extend<Expectations>({
|
||||
await style?.evaluate((tag) => tag.remove());
|
||||
|
||||
testInfo.annotations.push({
|
||||
// `_` prefix hides it from the HTML reporter
|
||||
type: "_screenshot",
|
||||
type: ANNOTATION,
|
||||
description: testInfo.snapshotPath(screenshotName),
|
||||
});
|
||||
|
||||
|
||||
@ -16,6 +16,12 @@ import path from "node:path";
|
||||
import { type Reporter, type TestCase } from "@playwright/test/reporter";
|
||||
import { type FullConfig } from "@playwright/test";
|
||||
|
||||
/**
|
||||
* The annotation type used to mark screenshots in tests.
|
||||
* `_` prefix hides it from the HTML reporter
|
||||
*/
|
||||
export const ANNOTATION = "_screenshot";
|
||||
|
||||
class StaleScreenshotReporter implements Reporter {
|
||||
private readonly snapshotRoots = new Set<string>();
|
||||
private readonly screenshots = new Set<string>();
|
||||
@ -34,7 +40,7 @@ class StaleScreenshotReporter implements Reporter {
|
||||
this.failing = true;
|
||||
}
|
||||
for (const annotation of test.annotations) {
|
||||
if (annotation.type === "_screenshot" && annotation.description) {
|
||||
if (annotation.type === ANNOTATION && annotation.description) {
|
||||
this.screenshots.add(annotation.description);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user