@empiricalrun/playwright-utils 0.16.0 → 0.16.2

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,17 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.16.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 8825df8: gcam "fix: custom page provider attaches multiple videos in report"
8
+
9
+ ## 0.16.1
10
+
11
+ ### Patch Changes
12
+
13
+ - f1ab4f3: feat: added custom context page provider
14
+
3
15
  ## 0.16.0
4
16
 
5
17
  ### Minor Changes
@@ -1,8 +1,14 @@
1
- import type { PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestType } from "@playwright/test";
1
+ import type { BrowserContext, BrowserContextOptions, Page, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestType } from "@playwright/test";
2
2
  import { injectLocatorHighlightScripts } from "./scripts";
3
3
  import { HighlighterOpts } from "./types";
4
- export declare const baseTestFixture: (testFn: TestType<PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>, options?: HighlighterOpts) => TestType<PlaywrightTestArgs & PlaywrightTestOptions & {
5
- [key: string]: any;
6
- }, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
4
+ type TestOptions = {
5
+ page: Page;
6
+ customContextPageProvider: (options?: BrowserContextOptions) => Promise<{
7
+ context: BrowserContext;
8
+ page: Page;
9
+ }>;
10
+ saveVideos: void;
11
+ };
12
+ export declare const baseTestFixture: (testFn: TestType<PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>, options?: HighlighterOpts) => TestType<PlaywrightTestArgs & PlaywrightTestOptions & TestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
7
13
  export { injectLocatorHighlightScripts };
8
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,eAAe,WAClB,SACN,kBAAkB,GAAG,qBAAqB,EAC1C,oBAAoB,GAAG,uBAAuB,CAC/C,YACQ,eAAe;;kDAYzB,CAAC;AAEF,OAAO,EAAE,6BAA6B,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,IAAI,EACJ,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,yBAAyB,EAAE,CACzB,OAAO,CAAC,EAAE,qBAAqB,KAC5B,OAAO,CAAC;QAAE,OAAO,EAAE,cAAc,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IACtD,UAAU,EAAE,IAAI,CAAC;CAClB,CAAC;AAIF,eAAO,MAAM,eAAe,WAClB,SACN,kBAAkB,GAAG,qBAAqB,EAC1C,oBAAoB,GAAG,uBAAuB,CAC/C,YACQ,eAAe,uHAwDzB,CAAC;AAEF,OAAO,EAAE,6BAA6B,EAAE,CAAC"}
@@ -1,8 +1,15 @@
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.injectLocatorHighlightScripts = exports.baseTestFixture = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const rimraf_1 = require("rimraf");
4
10
  const scripts_1 = require("./scripts");
5
11
  Object.defineProperty(exports, "injectLocatorHighlightScripts", { enumerable: true, get: function () { return scripts_1.injectLocatorHighlightScripts; } });
12
+ const videoStore = "videos-store";
6
13
  const baseTestFixture = function (testFn, options = {
7
14
  mousePointerHighlighter: true,
8
15
  locatorHighlighter: true,
@@ -13,6 +20,42 @@ const baseTestFixture = function (testFn, options = {
13
20
  (0, scripts_1.injectLocatorHighlightScripts)(page, options);
14
21
  await use(page);
15
22
  },
23
+ customContextPageProvider: async ({ browser }, use, testInfo) => {
24
+ const contexts = [];
25
+ async function createContext(options = {}) {
26
+ const pageContext = await browser.newContext({
27
+ ...options,
28
+ recordVideo: {
29
+ dir: path_1.default.join(testInfo.project.outputDir, videoStore, testInfo.testId),
30
+ },
31
+ });
32
+ contexts.push(pageContext);
33
+ const customPage = await pageContext.newPage();
34
+ (0, scripts_1.injectLocatorHighlightScripts)(customPage);
35
+ return { context: pageContext, page: customPage };
36
+ }
37
+ await use(createContext);
38
+ for (const context of contexts) {
39
+ await context.close();
40
+ }
41
+ },
42
+ saveVideos: [
43
+ // eslint-disable-next-line no-empty-pattern
44
+ async ({}, use, testInfo) => {
45
+ await use();
46
+ const pathToTestVideos = path_1.default.join(testInfo.project.outputDir, "videos-store", testInfo.testId);
47
+ if (fs_1.default.existsSync(pathToTestVideos)) {
48
+ for (let name of fs_1.default.readdirSync(pathToTestVideos)) {
49
+ await testInfo.attach("video", {
50
+ path: path_1.default.join(pathToTestVideos, name),
51
+ contentType: "video/webm",
52
+ });
53
+ }
54
+ (0, rimraf_1.rimrafSync)(pathToTestVideos);
55
+ }
56
+ },
57
+ { auto: true },
58
+ ],
16
59
  });
17
60
  };
18
61
  exports.baseTestFixture = baseTestFixture;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -40,6 +40,7 @@
40
40
  "playwright-core": "1.47.1",
41
41
  "playwright-extra": "^4.3.6",
42
42
  "puppeteer-extra-plugin-recaptcha": "^3.6.8",
43
+ "rimraf": "^6.0.1",
43
44
  "@empiricalrun/llm": "^0.9.27",
44
45
  "@empiricalrun/r2-uploader": "^0.3.7"
45
46
  },