@zest-pw/test 1.0.11 → 1.0.12

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/README.md CHANGED
@@ -262,6 +262,35 @@ test('TC-001: Test description', async ({ page }) => {
262
262
  });
263
263
  ```
264
264
 
265
+ ### Custom Fixtures (Screenshots Still Work)
266
+
267
+ If you need custom fixtures, extend the exported `test` from `@zest-pw/test`.
268
+ Automatic screenshots after `test.step()` will continue to work.
269
+
270
+ ```typescript
271
+ import { test as base, expect } from '@zest-pw/test';
272
+
273
+ type MyFixtures = {
274
+ userRole: string;
275
+ };
276
+
277
+ export const test = base.extend<MyFixtures>({
278
+ userRole: async ({}, use) => {
279
+ await use('admin');
280
+ },
281
+ });
282
+
283
+ test('TC-001: Uses custom fixture', async ({ page, userRole }) => {
284
+ await test.step('Open page', async () => {
285
+ await page.goto('https://playwright.dev/');
286
+ });
287
+
288
+ await test.step('Assert role', async () => {
289
+ await expect(userRole).toBe('admin');
290
+ });
291
+ });
292
+ ```
293
+
265
294
  ### Test Naming Convention
266
295
 
267
296
  Name your test files with test case keys for Zephyr integration:
@@ -1 +1 @@
1
- {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../fixtures/fixtures.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,IAAI,6OAQf,CAAC;AAKH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../fixtures/fixtures.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,IAAI,6OAAsC,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC"}
@@ -4,14 +4,28 @@ exports.expect = exports.test = void 0;
4
4
  const test_1 = require("@playwright/test");
5
5
  const test_step_wrapper_1 = require("../utils/test-step-wrapper");
6
6
  let currentTestContext = null;
7
- exports.test = test_1.test.extend({
7
+ const screenshotWrapperApplied = Symbol('zestScreenshotWrapperApplied');
8
+ function enableStepScreenshots(targetTest) {
9
+ const testWithMeta = targetTest;
10
+ if (testWithMeta[screenshotWrapperApplied]) {
11
+ return targetTest;
12
+ }
13
+ (0, test_step_wrapper_1.wrapTestStepWithScreenshots)(targetTest, () => currentTestContext);
14
+ testWithMeta[screenshotWrapperApplied] = true;
15
+ const originalExtend = targetTest.extend.bind(targetTest);
16
+ targetTest.extend = ((...args) => {
17
+ const extendedTest = originalExtend(...args);
18
+ return enableStepScreenshots(extendedTest);
19
+ });
20
+ return targetTest;
21
+ }
22
+ const zestBaseTest = test_1.test.extend({
8
23
  page: async ({ page }, use, testInfo) => {
9
24
  currentTestContext = { testInfo, page };
10
25
  await use(page);
11
26
  currentTestContext = null;
12
27
  },
13
28
  });
14
- // Apply wrapper to test.step for automatic screenshots
15
- (0, test_step_wrapper_1.wrapTestStepWithScreenshots)(exports.test, () => currentTestContext);
29
+ exports.test = enableStepScreenshots(zestBaseTest);
16
30
  var test_2 = require("@playwright/test");
17
31
  Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return test_2.expect; } });
@@ -1 +1 @@
1
- {"version":3,"file":"test-step-wrapper.d.ts","sourceRoot":"","sources":["../../utils/test-step-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAgB,IAAI,IAAI,IAAI,EAAY,MAAM,kBAAkB,CAAC;AAG7F;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,OAAO,IAAI,EACjB,iBAAiB,EAAE,MAAM;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,GACjE,IAAI,CAmCN"}
1
+ {"version":3,"file":"test-step-wrapper.d.ts","sourceRoot":"","sources":["../../utils/test-step-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAgB,IAAI,IAAI,IAAI,EAAY,MAAM,kBAAkB,CAAC;AAG7F;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,OAAO,IAAI,EACjB,iBAAiB,EAAE,MAAM;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,GACjE,IAAI,CAuCN"}
@@ -12,6 +12,9 @@ function wrapTestStepWithScreenshots(test, getCurrentContext) {
12
12
  const originalTestStepSkip = test.step.skip.bind(test);
13
13
  const takeScreenshot = async (title, hasError = false) => {
14
14
  const context = getCurrentContext();
15
+ if (!context) {
16
+ return;
17
+ }
15
18
  try {
16
19
  await (0, take_screenshots_1.takeScreenshotAfterStep)(context.page, context.testInfo, title, hasError);
17
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zest-pw/test",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Advanced Playwright test framework with automatic screenshots, custom reporting, and Zephyr Scale integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",