@zest-pw/test 1.0.10 → 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 +29 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -1
- package/dist/fixtures/fixtures.d.ts.map +1 -1
- package/dist/fixtures/fixtures.js +17 -3
- package/dist/utils/take-screenshots.d.ts.map +1 -1
- package/dist/utils/take-screenshots.js +1 -0
- package/dist/utils/test-step-wrapper.d.ts.map +1 -1
- package/dist/utils/test-step-wrapper.js +3 -0
- package/package.json +1 -1
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:
|
package/dist/config.d.ts.map
C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,CAAC,UAAU,CAAC,CAiBzE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,QAAQ,CAAC,UAAU,CAAC,CAEpD;AAED;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAgBpE"}
|
package/dist/config.js
CHANGED
|
@@ -130,7 +130,9 @@ async function loadZestConfig() {
|
|
|
130
130
|
const configPath = process.cwd() + '/zest.config.ts';
|
|
131
131
|
const userConfig = await Promise.resolve(`${configPath}`).then(s => __importStar(require(s)));
|
|
132
132
|
if (userConfig.default) {
|
|
133
|
-
|
|
133
|
+
// Update global loadedConfig so getZestConfig() returns the same values
|
|
134
|
+
loadedConfig = userConfig.default;
|
|
135
|
+
return loadedConfig;
|
|
134
136
|
}
|
|
135
137
|
return loadedConfig;
|
|
136
138
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../fixtures/fixtures.ts"],"names":[],"mappings":"
|
|
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
|
-
|
|
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
|
-
|
|
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":"take-screenshots.d.ts","sourceRoot":"","sources":["../../utils/take-screenshots.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGvD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,OAAO,GACjB,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"take-screenshots.d.ts","sourceRoot":"","sources":["../../utils/take-screenshots.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGvD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,OAAO,GACjB,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
|
|
@@ -32,6 +32,7 @@ async function takeScreenshotAfterStep(page, testInfo, stepTitle, hasError) {
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
// Check if we should only take screenshots on failure
|
|
35
|
+
// If onlyOnFailure is true, only take screenshot when hasError is explicitly true
|
|
35
36
|
if (config.screenshots.onlyOnFailure && !hasError) {
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
@@ -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,
|
|
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