@zest-pw/test 1.0.8 → 1.0.10
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/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/reporter/result-processor.d.ts.map +1 -1
- package/dist/reporter/result-processor.js +34 -1
- package/dist/utils/take-screenshots.d.ts +9 -3
- package/dist/utils/take-screenshots.d.ts.map +1 -1
- package/dist/utils/take-screenshots.js +22 -4
- package/dist/utils/test-step-wrapper.js +4 -4
- package/dist/zephyr-api/get-results-from-json.d.ts.map +1 -1
- package/dist/zephyr-api/get-results-from-json.js +3 -0
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -55,6 +55,11 @@ export interface ZestConfig {
|
|
|
55
55
|
* @default false
|
|
56
56
|
*/
|
|
57
57
|
saveToDisk?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Capture full page screenshot (scrolls to capture entire page)
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
fullPage?: boolean;
|
|
58
63
|
};
|
|
59
64
|
/**
|
|
60
65
|
* Zephyr Scale integration settings
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT;;;WAGG;QACH,cAAc,CAAC,EAAE,OAAO,CAAC;QAEzB;;;WAGG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB;;;WAGG;QACH,cAAc,CAAC,EAAE,OAAO,CAAC;QAEzB;;;;WAIG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IAEF;;OAEG;IACH,WAAW,CAAC,EAAE;QACZ;;;WAGG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;QA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gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,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,CAcpE"}
|
package/dist/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-processor.d.ts","sourceRoot":"","sources":["../../reporter/result-processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAUlF;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"result-processor.d.ts","sourceRoot":"","sources":["../../reporter/result-processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAUlF;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC,iBAsD3D"}
|
|
@@ -23,10 +23,14 @@ async function processTestResults(fullResult, testResults) {
|
|
|
23
23
|
const enrichedResults = (0, enrich_test_results_1.enrichTestResultsWithPlannedSteps)(transformedResults);
|
|
24
24
|
// Add formatted file names to actualResult
|
|
25
25
|
const finalResults = (0, add_file_names_1.addFileNamesToResults)(enrichedResults);
|
|
26
|
+
// Remove screenshot bodies from report if includeInReport is false
|
|
27
|
+
const resultsForReport = config.screenshots.includeInReport
|
|
28
|
+
? finalResults
|
|
29
|
+
: removeScreenshotBodies(finalResults);
|
|
26
30
|
// Save JSON report if enabled
|
|
27
31
|
if (config.reporter.saveJsonReport) {
|
|
28
32
|
try {
|
|
29
|
-
(0, save_json_report_1.saveTestResultsToJson)(
|
|
33
|
+
(0, save_json_report_1.saveTestResultsToJson)(resultsForReport, config.reporter.outputDir);
|
|
30
34
|
}
|
|
31
35
|
catch (error) {
|
|
32
36
|
console.error('Error saving JSON report:', error);
|
|
@@ -60,3 +64,32 @@ async function processTestResults(fullResult, testResults) {
|
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Removes screenshot bodies (base64 data) from test results while keeping metadata
|
|
69
|
+
* This is used when includeInReport is false to reduce JSON file size
|
|
70
|
+
* @param results - Test results object
|
|
71
|
+
* @returns Test results with screenshot bodies removed
|
|
72
|
+
*/
|
|
73
|
+
function removeScreenshotBodies(results) {
|
|
74
|
+
return {
|
|
75
|
+
...results,
|
|
76
|
+
tests: results.tests.map((test) => ({
|
|
77
|
+
...test,
|
|
78
|
+
steps: test.steps.map((step) => ({
|
|
79
|
+
...step,
|
|
80
|
+
actualResult: step.actualResult?.map((att) => {
|
|
81
|
+
// If it's a screenshot (image/png), remove the body but keep metadata
|
|
82
|
+
if (att.image === 'image/png') {
|
|
83
|
+
return {
|
|
84
|
+
fileName: att.fileName,
|
|
85
|
+
image: att.image,
|
|
86
|
+
// body is omitted
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
// For other attachments, keep as is
|
|
90
|
+
return att;
|
|
91
|
+
}) || []
|
|
92
|
+
}))
|
|
93
|
+
}))
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -3,16 +3,22 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { Page, TestInfo } from "@playwright/test";
|
|
5
5
|
/**
|
|
6
|
-
* Takes a screenshot after each test step
|
|
6
|
+
* Takes a screenshot after each test step
|
|
7
|
+
*
|
|
8
|
+
* Screenshot behavior is controlled by configuration:
|
|
9
|
+
* - screenshots.enabled: If false, no screenshots are taken
|
|
10
|
+
* - screenshots.onlyOnFailure: If true, screenshots are only taken when step fails
|
|
11
|
+
* - screenshots.fullPage: Controls whether to capture full page or viewport only
|
|
7
12
|
*
|
|
8
13
|
* To save screenshots to disk (from base64 results):
|
|
9
14
|
* 1. Add to .env file: SAVE_SCREENSHOTS=true
|
|
10
15
|
* 2. Or pass via command: SAVE_SCREENSHOTS=true npx playwright test
|
|
16
|
+
* 3. Or set screenshots.saveToDisk: true in config
|
|
11
17
|
*
|
|
12
18
|
* @param page - Playwright Page object
|
|
13
|
-
* @param stepInfo - Step information object
|
|
14
19
|
* @param testInfo - Playwright TestInfo object for attaching screenshots
|
|
15
20
|
* @param stepTitle - Optional step title for attachment name
|
|
21
|
+
* @param hasError - Whether the step failed (used for onlyOnFailure logic)
|
|
16
22
|
*/
|
|
17
|
-
export declare function takeScreenshotAfterStep(page: Page, testInfo: TestInfo, stepTitle?: string): Promise<void>;
|
|
23
|
+
export declare function takeScreenshotAfterStep(page: Page, testInfo: TestInfo, stepTitle?: string, hasError?: boolean): Promise<void>;
|
|
18
24
|
//# sourceMappingURL=take-screenshots.d.ts.map
|
|
@@ -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;
|
|
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,CA2Bf"}
|
|
@@ -4,22 +4,40 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.takeScreenshotAfterStep = takeScreenshotAfterStep;
|
|
7
|
+
const config_1 = require("../config");
|
|
7
8
|
/**
|
|
8
|
-
* Takes a screenshot after each test step
|
|
9
|
+
* Takes a screenshot after each test step
|
|
10
|
+
*
|
|
11
|
+
* Screenshot behavior is controlled by configuration:
|
|
12
|
+
* - screenshots.enabled: If false, no screenshots are taken
|
|
13
|
+
* - screenshots.onlyOnFailure: If true, screenshots are only taken when step fails
|
|
14
|
+
* - screenshots.fullPage: Controls whether to capture full page or viewport only
|
|
9
15
|
*
|
|
10
16
|
* To save screenshots to disk (from base64 results):
|
|
11
17
|
* 1. Add to .env file: SAVE_SCREENSHOTS=true
|
|
12
18
|
* 2. Or pass via command: SAVE_SCREENSHOTS=true npx playwright test
|
|
19
|
+
* 3. Or set screenshots.saveToDisk: true in config
|
|
13
20
|
*
|
|
14
21
|
* @param page - Playwright Page object
|
|
15
|
-
* @param stepInfo - Step information object
|
|
16
22
|
* @param testInfo - Playwright TestInfo object for attaching screenshots
|
|
17
23
|
* @param stepTitle - Optional step title for attachment name
|
|
24
|
+
* @param hasError - Whether the step failed (used for onlyOnFailure logic)
|
|
18
25
|
*/
|
|
19
|
-
async function takeScreenshotAfterStep(page, testInfo, stepTitle) {
|
|
26
|
+
async function takeScreenshotAfterStep(page, testInfo, stepTitle, hasError) {
|
|
20
27
|
try {
|
|
21
28
|
if (page && testInfo) {
|
|
22
|
-
const
|
|
29
|
+
const config = (0, config_1.getZestConfig)();
|
|
30
|
+
// Check if screenshots are enabled
|
|
31
|
+
if (!config.screenshots.enabled) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
// Check if we should only take screenshots on failure
|
|
35
|
+
if (config.screenshots.onlyOnFailure && !hasError) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const screenshotBuffer = await page.screenshot({
|
|
39
|
+
fullPage: config.screenshots.fullPage
|
|
40
|
+
});
|
|
23
41
|
await testInfo.attach(stepTitle || 'screenshot', {
|
|
24
42
|
body: screenshotBuffer,
|
|
25
43
|
contentType: 'image/png',
|
|
@@ -10,10 +10,10 @@ const take_screenshots_1 = require("./take-screenshots");
|
|
|
10
10
|
function wrapTestStepWithScreenshots(test, getCurrentContext) {
|
|
11
11
|
const originalTestStep = test.step.bind(test);
|
|
12
12
|
const originalTestStepSkip = test.step.skip.bind(test);
|
|
13
|
-
const takeScreenshot = async (title) => {
|
|
13
|
+
const takeScreenshot = async (title, hasError = false) => {
|
|
14
14
|
const context = getCurrentContext();
|
|
15
15
|
try {
|
|
16
|
-
await (0, take_screenshots_1.takeScreenshotAfterStep)(context.page, context.testInfo, title);
|
|
16
|
+
await (0, take_screenshots_1.takeScreenshotAfterStep)(context.page, context.testInfo, title, hasError);
|
|
17
17
|
}
|
|
18
18
|
catch (screenshotError) {
|
|
19
19
|
console.error('Error taking screenshot after step error:', screenshotError);
|
|
@@ -23,11 +23,11 @@ function wrapTestStepWithScreenshots(test, getCurrentContext) {
|
|
|
23
23
|
return originalTestStep(title, async (stepInfo) => {
|
|
24
24
|
try {
|
|
25
25
|
const result = await body(stepInfo);
|
|
26
|
-
await takeScreenshot(title);
|
|
26
|
+
await takeScreenshot(title, false);
|
|
27
27
|
return result;
|
|
28
28
|
}
|
|
29
29
|
catch (error) {
|
|
30
|
-
await takeScreenshot(title);
|
|
30
|
+
await takeScreenshot(title, true);
|
|
31
31
|
throw error;
|
|
32
32
|
}
|
|
33
33
|
}, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-results-from-json.d.ts","sourceRoot":"","sources":["../../zephyr-api/get-results-from-json.ts"],"names":[],"mappings":"AAqBA;;;;;GAKG;AACH,wBAAsB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"get-results-from-json.d.ts","sourceRoot":"","sources":["../../zephyr-api/get-results-from-json.ts"],"names":[],"mappings":"AAqBA;;;;;GAKG;AACH,wBAAsB,kBAAkB,iBA0CvC"}
|
|
@@ -82,6 +82,9 @@ async function getResultsFromJson() {
|
|
|
82
82
|
const errorHtml = `<div style="min-width: 800px; margin: 5px; max-width: 900px;"><div style="background-color: #d32f2f; color: white; text-align: center; font-family: monospace; font-size: 16px;">ERROR</div><div style="padding: 15px; font-family: monospace; white-space: pre-wrap;">${errorMessage}</div><div style="background-color: #d32f2f; color: white; text-align: center; font-family: monospace; font-size: 16px;">ERROR</div></div>`;
|
|
83
83
|
processedError = errorHtml;
|
|
84
84
|
}
|
|
85
|
+
else {
|
|
86
|
+
processedError = '';
|
|
87
|
+
}
|
|
85
88
|
return {
|
|
86
89
|
actualResult: processedError + '\n' + processedActualResult,
|
|
87
90
|
...step
|
package/package.json
CHANGED