@empiricalrun/playwright-utils 0.48.4 → 0.48.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.48.5
4
+
5
+ ### Patch Changes
6
+
7
+ - e00de0e: fix: visual assertions attachments should be path-based
8
+ - 448e699: chore: simplify webhook assertions
9
+
3
10
  ## 0.48.4
4
11
 
5
12
  ### Patch Changes
@@ -10,7 +10,8 @@ const expect = (0, test_1.extendExpect)(fixtures_1.expect);
10
10
  expect(pageAttachment).toBeDefined();
11
11
  expect(pageAttachment.name).toBe("toLookRight-L11-a-welcome-page-with-a-heading-and-a-paragraph-of-text");
12
12
  expect(pageAttachment.contentType).toBe("image/png");
13
- expect(pageAttachment.body.length).toBeGreaterThan(0);
13
+ expect(pageAttachment.path).toBeDefined();
14
+ expect(pageAttachment.path).toMatch(/\.png$/);
14
15
  });
15
16
  (0, fixtures_1.test)("toLookRight on locator attaches screenshot", async ({ page, server, }, testInfo) => {
16
17
  await page.goto(`${server.baseURL}/visual-test.html`);
@@ -18,7 +19,8 @@ const expect = (0, test_1.extendExpect)(fixtures_1.expect);
18
19
  await expect(heading).toLookRight("A heading that says Welcome to the App");
19
20
  const locatorAttachment = testInfo.attachments.find((a) => a.name.startsWith("toLookRight-"));
20
21
  expect(locatorAttachment).toBeDefined();
21
- expect(locatorAttachment.name).toBe("toLookRight-L31-a-heading-that-says-welcome-to-the-app");
22
+ expect(locatorAttachment.name).toBe("toLookRight-L32-a-heading-that-says-welcome-to-the-app");
22
23
  expect(locatorAttachment.contentType).toBe("image/png");
23
- expect(locatorAttachment.body.length).toBeGreaterThan(0);
24
+ expect(locatorAttachment.path).toBeDefined();
25
+ expect(locatorAttachment.path).toMatch(/\.png$/);
24
26
  });
@@ -1 +1 @@
1
- {"version":3,"file":"visual.d.ts","sourceRoot":"","sources":["../../../src/test/expect/visual.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAY,MAAM,kBAAkB,CAAC;AAOhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AA8D7C,wBAAsB,WAAW,CAC/B,MAAM,EAAE,IAAI,GAAG,OAAO,EACtB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,aAAa,CAAC,CA2FxB"}
1
+ {"version":3,"file":"visual.d.ts","sourceRoot":"","sources":["../../../src/test/expect/visual.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAY,MAAM,kBAAkB,CAAC;AAUhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAsE7C,wBAAsB,WAAW,CAC/B,MAAM,EAAE,IAAI,GAAG,OAAO,EACtB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,aAAa,CAAC,CA2FxB"}
@@ -1,8 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.toLookRight = toLookRight;
4
7
  const llm_1 = require("@empiricalrun/llm");
5
8
  const vision_1 = require("@empiricalrun/llm/vision");
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const os_1 = __importDefault(require("os"));
11
+ const path_1 = __importDefault(require("path"));
6
12
  const telemetry_1 = require("../../telemetry");
7
13
  const mouse_pointer_1 = require("../scripts/mouse-pointer");
8
14
  function getCallerLine() {
@@ -29,8 +35,13 @@ function attachScreenshot(screenshot, pageDescription) {
29
35
  .replace(/[^a-z0-9]+/g, "-")
30
36
  .replace(/(^-|-$)/g, "");
31
37
  const line = getCallerLine();
32
- testInfo.attach(`toLookRight-L${line}-${slug}`, {
33
- body: screenshot,
38
+ const attachmentName = `toLookRight-L${line}-${slug}`;
39
+ // Write to a temp file so the attachment has a path (required by empirical reporter).
40
+ // Playwright copies it into test-results/<test>/attachments/ on attach.
41
+ const tmpFile = path_1.default.join(os_1.default.tmpdir(), `${attachmentName}-${Date.now()}.png`);
42
+ fs_1.default.writeFileSync(tmpFile, screenshot);
43
+ testInfo.attach(attachmentName, {
44
+ path: tmpFile,
34
45
  contentType: "image/png",
35
46
  });
36
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.48.4",
3
+ "version": "0.48.5",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"