@zest-pw/test 1.0.0
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/LICENSE +22 -0
- package/README.md +415 -0
- package/dist/config.d.ts +127 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +140 -0
- package/dist/fixtures/fixtures.d.ts +3 -0
- package/dist/fixtures/fixtures.d.ts.map +1 -0
- package/dist/fixtures/fixtures.js +24 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/reporter/custom-reporter.d.ts +11 -0
- package/dist/reporter/custom-reporter.d.ts.map +1 -0
- package/dist/reporter/custom-reporter.js +19 -0
- package/dist/reporter/result-processor.d.ts +11 -0
- package/dist/reporter/result-processor.d.ts.map +1 -0
- package/dist/reporter/result-processor.js +52 -0
- package/dist/reporter/test-results-store.d.ts +31 -0
- package/dist/reporter/test-results-store.d.ts.map +1 -0
- package/dist/reporter/test-results-store.js +38 -0
- package/dist/utils/add-file-names.d.ts +9 -0
- package/dist/utils/add-file-names.d.ts.map +1 -0
- package/dist/utils/add-file-names.js +39 -0
- package/dist/utils/enrich-test-results.d.ts +6 -0
- package/dist/utils/enrich-test-results.d.ts.map +1 -0
- package/dist/utils/enrich-test-results.js +113 -0
- package/dist/utils/parse-test-steps.d.ts +8 -0
- package/dist/utils/parse-test-steps.d.ts.map +1 -0
- package/dist/utils/parse-test-steps.js +110 -0
- package/dist/utils/save-json-report.d.ts +17 -0
- package/dist/utils/save-json-report.d.ts.map +1 -0
- package/dist/utils/save-json-report.js +75 -0
- package/dist/utils/save-screenshots.d.ts +9 -0
- package/dist/utils/save-screenshots.d.ts.map +1 -0
- package/dist/utils/save-screenshots.js +66 -0
- package/dist/utils/take-screenshots.d.ts +13 -0
- package/dist/utils/take-screenshots.d.ts.map +1 -0
- package/dist/utils/take-screenshots.js +34 -0
- package/dist/utils/terminal-reporter.d.ts +8 -0
- package/dist/utils/terminal-reporter.d.ts.map +1 -0
- package/dist/utils/terminal-reporter.js +140 -0
- package/dist/utils/test-result-transformer.d.ts +13 -0
- package/dist/utils/test-result-transformer.d.ts.map +1 -0
- package/dist/utils/test-result-transformer.js +109 -0
- package/dist/utils/test-step-wrapper.d.ts +13 -0
- package/dist/utils/test-step-wrapper.d.ts.map +1 -0
- package/dist/utils/test-step-wrapper.js +48 -0
- package/dist/zephyr-api/get-results-from-json.d.ts +2 -0
- package/dist/zephyr-api/get-results-from-json.d.ts.map +1 -0
- package/dist/zephyr-api/get-results-from-json.js +71 -0
- package/dist/zephyr-api/update-execution-result.d.ts +2 -0
- package/dist/zephyr-api/update-execution-result.d.ts.map +1 -0
- package/dist/zephyr-api/update-execution-result.js +26 -0
- package/dist/zephyr-api/zephyr-api.d.ts +19 -0
- package/dist/zephyr-api/zephyr-api.d.ts.map +1 -0
- package/dist/zephyr-api/zephyr-api.js +89 -0
- package/package.json +69 -0
- package/scripts/install-config.js +92 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.expect = exports.test = void 0;
|
|
4
|
+
const test_1 = require("@playwright/test");
|
|
5
|
+
const test_step_wrapper_1 = require("../utils/test-step-wrapper");
|
|
6
|
+
// Глобальна змінна для зберігання поточного контексту тесту
|
|
7
|
+
let currentTestContext = null;
|
|
8
|
+
// Розширюємо базовий test з кастомним fixture для зберігання контексту
|
|
9
|
+
exports.test = test_1.test.extend({
|
|
10
|
+
page: async ({ page }, use, testInfo) => {
|
|
11
|
+
// Зберігаємо контекст перед використанням page
|
|
12
|
+
currentTestContext = { testInfo, page };
|
|
13
|
+
await use(page);
|
|
14
|
+
// Очищаємо контекст після використання
|
|
15
|
+
currentTestContext = null;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
// Застосовуємо обгортку до test.step для автоматичних скріншотів
|
|
19
|
+
(0, test_step_wrapper_1.wrapTestStepWithScreenshots)(exports.test, () => currentTestContext);
|
|
20
|
+
// Примітка: Контекст тесту (page та testInfo) зберігається через custom fixture
|
|
21
|
+
// Скріншоти створюються автоматично після кожного test.step()
|
|
22
|
+
// Виведення результатів тестів відбувається через кастомний Reporter (custom-reporter.ts)
|
|
23
|
+
var test_2 = require("@playwright/test");
|
|
24
|
+
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return test_2.expect; } });
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zest Playwright Framework
|
|
3
|
+
*
|
|
4
|
+
* Main entry point for the Zest Playwright test framework
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export { defineZestConfig, getZestConfig, loadZestConfig, defaultConfig, type ZestConfig, } from './config';
|
|
9
|
+
export { test, expect } from './fixtures/fixtures';
|
|
10
|
+
export { default as CustomReporter } from './reporter/custom-reporter';
|
|
11
|
+
export type { TestCase, TestResult, FullResult, Reporter, } from '@playwright/test/reporter';
|
|
12
|
+
export declare const VERSION = "1.0.0";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,aAAa,EACb,KAAK,UAAU,GAChB,MAAM,UAAU,CAAC;AAKlB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAKnD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAKvE,YAAY,EACV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,QAAQ,GACT,MAAM,2BAA2B,CAAC;AAKnC,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Zest Playwright Framework
|
|
4
|
+
*
|
|
5
|
+
* Main entry point for the Zest Playwright test framework
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.VERSION = exports.CustomReporter = exports.expect = exports.test = exports.defaultConfig = exports.loadZestConfig = exports.getZestConfig = exports.defineZestConfig = void 0;
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Configuration
|
|
16
|
+
// ============================================================================
|
|
17
|
+
var config_1 = require("./config");
|
|
18
|
+
Object.defineProperty(exports, "defineZestConfig", { enumerable: true, get: function () { return config_1.defineZestConfig; } });
|
|
19
|
+
Object.defineProperty(exports, "getZestConfig", { enumerable: true, get: function () { return config_1.getZestConfig; } });
|
|
20
|
+
Object.defineProperty(exports, "loadZestConfig", { enumerable: true, get: function () { return config_1.loadZestConfig; } });
|
|
21
|
+
Object.defineProperty(exports, "defaultConfig", { enumerable: true, get: function () { return config_1.defaultConfig; } });
|
|
22
|
+
// ============================================================================
|
|
23
|
+
// Fixtures
|
|
24
|
+
// ============================================================================
|
|
25
|
+
var fixtures_1 = require("./fixtures/fixtures");
|
|
26
|
+
Object.defineProperty(exports, "test", { enumerable: true, get: function () { return fixtures_1.test; } });
|
|
27
|
+
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return fixtures_1.expect; } });
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// Reporter
|
|
30
|
+
// ============================================================================
|
|
31
|
+
var custom_reporter_1 = require("./reporter/custom-reporter");
|
|
32
|
+
Object.defineProperty(exports, "CustomReporter", { enumerable: true, get: function () { return __importDefault(custom_reporter_1).default; } });
|
|
33
|
+
// ============================================================================
|
|
34
|
+
// Version
|
|
35
|
+
// ============================================================================
|
|
36
|
+
exports.VERSION = '1.0.0';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Reporter, FullResult, TestCase, TestResult } from '@playwright/test/reporter';
|
|
2
|
+
/**
|
|
3
|
+
* Custom reporter for outputting detailed test results with step information
|
|
4
|
+
*/
|
|
5
|
+
declare class CustomReporter implements Reporter {
|
|
6
|
+
private store;
|
|
7
|
+
onTestEnd(test: TestCase, result: TestResult): Promise<void>;
|
|
8
|
+
onEnd(fullResult: FullResult): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export default CustomReporter;
|
|
11
|
+
//# sourceMappingURL=custom-reporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-reporter.d.ts","sourceRoot":"","sources":["../../reporter/custom-reporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAI5F;;GAEG;AACH,cAAM,cAAe,YAAW,QAAQ;IACtC,OAAO,CAAC,KAAK,CAA0B;IAEjC,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU;IAI5C,KAAK,CAAC,UAAU,EAAE,UAAU;CAGnC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const result_processor_1 = require("./result-processor");
|
|
4
|
+
const test_results_store_1 = require("./test-results-store");
|
|
5
|
+
/**
|
|
6
|
+
* Custom reporter for outputting detailed test results with step information
|
|
7
|
+
*/
|
|
8
|
+
class CustomReporter {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.store = new test_results_store_1.TestResultsStore();
|
|
11
|
+
}
|
|
12
|
+
async onTestEnd(test, result) {
|
|
13
|
+
this.store.add(test, result);
|
|
14
|
+
}
|
|
15
|
+
async onEnd(fullResult) {
|
|
16
|
+
await (0, result_processor_1.processTestResults)(fullResult, this.store.getAll());
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.default = CustomReporter;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FullResult, TestCase, TestResult } from '@playwright/test/reporter';
|
|
2
|
+
/**
|
|
3
|
+
* Processes test results: transforms, enriches, saves to JSON, prints to console, and updates in Zephyr
|
|
4
|
+
* @param fullResult - Full test execution result from Playwright
|
|
5
|
+
* @param testResults - Array of individual test results with test cases
|
|
6
|
+
*/
|
|
7
|
+
export declare function processTestResults(fullResult: FullResult, testResults: Array<{
|
|
8
|
+
test: TestCase;
|
|
9
|
+
result: TestResult;
|
|
10
|
+
}>): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=result-processor.d.ts.map
|
|
@@ -0,0 +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;AASlF;;;;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,iBAwC3D"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processTestResults = processTestResults;
|
|
4
|
+
const terminal_reporter_1 = require("../utils/terminal-reporter");
|
|
5
|
+
const test_result_transformer_1 = require("../utils/test-result-transformer");
|
|
6
|
+
const save_json_report_1 = require("../utils/save-json-report");
|
|
7
|
+
const enrich_test_results_1 = require("../utils/enrich-test-results");
|
|
8
|
+
const add_file_names_1 = require("../utils/add-file-names");
|
|
9
|
+
const update_execution_result_1 = require("../zephyr-api/update-execution-result");
|
|
10
|
+
const config_1 = require("../config");
|
|
11
|
+
/**
|
|
12
|
+
* Processes test results: transforms, enriches, saves to JSON, prints to console, and updates in Zephyr
|
|
13
|
+
* @param fullResult - Full test execution result from Playwright
|
|
14
|
+
* @param testResults - Array of individual test results with test cases
|
|
15
|
+
*/
|
|
16
|
+
async function processTestResults(fullResult, testResults) {
|
|
17
|
+
// Load configuration
|
|
18
|
+
const config = await (0, config_1.loadZestConfig)();
|
|
19
|
+
// Transform test results into extended format with step information
|
|
20
|
+
const transformedResults = (0, test_result_transformer_1.transformTestResults)(fullResult, testResults);
|
|
21
|
+
// Enrich results with planned steps (for JSON and console)
|
|
22
|
+
const enrichedResults = (0, enrich_test_results_1.enrichTestResultsWithPlannedSteps)(transformedResults);
|
|
23
|
+
// Add formatted file names to actualResult
|
|
24
|
+
const finalResults = (0, add_file_names_1.addFileNamesToResults)(enrichedResults);
|
|
25
|
+
// Save JSON report if enabled
|
|
26
|
+
if (config.reporter.saveJsonReport) {
|
|
27
|
+
try {
|
|
28
|
+
(0, save_json_report_1.saveTestResultsToJson)(finalResults, config.reporter.outputDir);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.error('Error saving JSON report:', error);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Print test results to console if enabled
|
|
35
|
+
if (config.reporter.printToConsole) {
|
|
36
|
+
try {
|
|
37
|
+
(0, terminal_reporter_1.printTestResults)(finalResults);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
console.error('Error printing test results:', error);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Update test results in Zephyr if enabled
|
|
44
|
+
if (config.zephyr.enabled && config.zephyr.updateResults) {
|
|
45
|
+
try {
|
|
46
|
+
await (0, update_execution_result_1.updateTestResult)();
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error('Error updating test results:', error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { TestCase, TestResult } from '@playwright/test/reporter';
|
|
2
|
+
/**
|
|
3
|
+
* Store for collecting test results during test execution
|
|
4
|
+
*
|
|
5
|
+
* Methods:
|
|
6
|
+
* - add(test, result) - Adds a test result to the store
|
|
7
|
+
* - getAll() - Gets all stored test results
|
|
8
|
+
* - clear() - Clears all stored test results
|
|
9
|
+
*/
|
|
10
|
+
export declare class TestResultsStore {
|
|
11
|
+
private results;
|
|
12
|
+
/**
|
|
13
|
+
* Adds a test result to the store
|
|
14
|
+
* @param test - Test case information
|
|
15
|
+
* @param result - Test execution result
|
|
16
|
+
*/
|
|
17
|
+
add(test: TestCase, result: TestResult): void;
|
|
18
|
+
/**
|
|
19
|
+
* Gets all stored test results
|
|
20
|
+
* @returns Array of test results with test cases
|
|
21
|
+
*/
|
|
22
|
+
getAll(): Array<{
|
|
23
|
+
test: TestCase;
|
|
24
|
+
result: TestResult;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Clears all stored test results
|
|
28
|
+
*/
|
|
29
|
+
clear(): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=test-results-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-results-store.d.ts","sourceRoot":"","sources":["../../reporter/test-results-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;;;;;;GAOG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAqD;IAEpE;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI;IAI7C;;;OAGG;IACH,MAAM,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAE,CAAC;IAIvD;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TestResultsStore = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Store for collecting test results during test execution
|
|
6
|
+
*
|
|
7
|
+
* Methods:
|
|
8
|
+
* - add(test, result) - Adds a test result to the store
|
|
9
|
+
* - getAll() - Gets all stored test results
|
|
10
|
+
* - clear() - Clears all stored test results
|
|
11
|
+
*/
|
|
12
|
+
class TestResultsStore {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.results = [];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Adds a test result to the store
|
|
18
|
+
* @param test - Test case information
|
|
19
|
+
* @param result - Test execution result
|
|
20
|
+
*/
|
|
21
|
+
add(test, result) {
|
|
22
|
+
this.results.push({ test, result });
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets all stored test results
|
|
26
|
+
* @returns Array of test results with test cases
|
|
27
|
+
*/
|
|
28
|
+
getAll() {
|
|
29
|
+
return this.results;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Clears all stored test results
|
|
33
|
+
*/
|
|
34
|
+
clear() {
|
|
35
|
+
this.results = [];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.TestResultsStore = TestResultsStore;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds formatted file names to actualResult of each step
|
|
3
|
+
* Regenerates fileName for PNG screenshots based on step title and index
|
|
4
|
+
*
|
|
5
|
+
* @param results - Test results object with tests and steps
|
|
6
|
+
* @returns Updated results with formatted file names
|
|
7
|
+
*/
|
|
8
|
+
export declare function addFileNamesToResults(results: any): any;
|
|
9
|
+
//# sourceMappingURL=add-file-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-file-names.d.ts","sourceRoot":"","sources":["../../utils/add-file-names.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,CA+BvD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addFileNamesToResults = addFileNamesToResults;
|
|
4
|
+
/**
|
|
5
|
+
* Adds formatted file names to actualResult of each step
|
|
6
|
+
* Regenerates fileName for PNG screenshots based on step title and index
|
|
7
|
+
*
|
|
8
|
+
* @param results - Test results object with tests and steps
|
|
9
|
+
* @returns Updated results with formatted file names
|
|
10
|
+
*/
|
|
11
|
+
function addFileNamesToResults(results) {
|
|
12
|
+
if (!results.tests || !Array.isArray(results.tests)) {
|
|
13
|
+
return results;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
...results,
|
|
17
|
+
tests: results.tests.map((test) => ({
|
|
18
|
+
...test,
|
|
19
|
+
steps: test.steps?.map((step, stepIndex) => ({
|
|
20
|
+
...step,
|
|
21
|
+
actualResult: step.actualResult?.map((att) => {
|
|
22
|
+
// If it's a PNG screenshot, generate a formatted file name
|
|
23
|
+
if (att.image === 'image/png') {
|
|
24
|
+
const stepTitle = step.stepTitle.replace(/[^a-z0-9]/gi, '_').toLowerCase();
|
|
25
|
+
const isError = att.fileName?.includes('ERROR');
|
|
26
|
+
const errorSuffix = isError ? '_ERROR' : '';
|
|
27
|
+
const fileName = `step_${stepIndex + 1}_${stepTitle}${errorSuffix}.png`;
|
|
28
|
+
return {
|
|
29
|
+
...att,
|
|
30
|
+
fileName: fileName
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// For other attachment types, keep as is
|
|
34
|
+
return att;
|
|
35
|
+
}) || []
|
|
36
|
+
})) || []
|
|
37
|
+
}))
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Збагачує результати тестів запланованими кроками з файлів
|
|
3
|
+
* Додає кроки які не були виконані (наприклад після падіння тесту)
|
|
4
|
+
*/
|
|
5
|
+
export declare function enrichTestResultsWithPlannedSteps(results: any): any;
|
|
6
|
+
//# sourceMappingURL=enrich-test-results.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrich-test-results.d.ts","sourceRoot":"","sources":["../../utils/enrich-test-results.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,CASnE"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.enrichTestResultsWithPlannedSteps = enrichTestResultsWithPlannedSteps;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const parse_test_steps_1 = require("./parse-test-steps");
|
|
39
|
+
/**
|
|
40
|
+
* Збагачує результати тестів запланованими кроками з файлів
|
|
41
|
+
* Додає кроки які не були виконані (наприклад після падіння тесту)
|
|
42
|
+
*/
|
|
43
|
+
function enrichTestResultsWithPlannedSteps(results) {
|
|
44
|
+
if (!results.tests || !Array.isArray(results.tests)) {
|
|
45
|
+
return results;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
...results,
|
|
49
|
+
tests: results.tests.map((test) => enrichTestWithPlannedSteps(test))
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Збагачує один тест запланованими кроками
|
|
54
|
+
*/
|
|
55
|
+
function enrichTestWithPlannedSteps(test) {
|
|
56
|
+
const userSteps = filterUserSteps(test.steps || []);
|
|
57
|
+
const plannedSteps = getPlannedSteps(test);
|
|
58
|
+
const allSteps = combineSteps(userSteps, plannedSteps);
|
|
59
|
+
// Видаляємо _fullPath перед поверненням (використовувався тільки для getPlannedSteps)
|
|
60
|
+
const { _fullPath, ...testWithoutFullPath } = test;
|
|
61
|
+
return {
|
|
62
|
+
...testWithoutFullPath,
|
|
63
|
+
steps: allSteps
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Фільтрує тільки користувацькі кроки (приховує системні хуки)
|
|
68
|
+
*/
|
|
69
|
+
function filterUserSteps(steps) {
|
|
70
|
+
return steps.filter((step) => {
|
|
71
|
+
const title = step.stepTitle || '';
|
|
72
|
+
const lowerTitle = title.toLowerCase();
|
|
73
|
+
return (!lowerTitle.includes('before hooks') &&
|
|
74
|
+
!lowerTitle.includes('after hooks') &&
|
|
75
|
+
!lowerTitle.includes('worker cleanup') &&
|
|
76
|
+
!lowerTitle.includes('cleanup') &&
|
|
77
|
+
!title.startsWith('hook@') &&
|
|
78
|
+
!title.startsWith('fixture@') &&
|
|
79
|
+
!title.startsWith('pw:api@') &&
|
|
80
|
+
!title.startsWith('test.attach@') &&
|
|
81
|
+
!title.startsWith('test.before') &&
|
|
82
|
+
!title.startsWith('test.after'));
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Отримує заплановані кроки з файлу тесту
|
|
87
|
+
*/
|
|
88
|
+
function getPlannedSteps(test) {
|
|
89
|
+
// Використовуємо _fullPath який створюється в transformTestCase
|
|
90
|
+
const fullPath = test._fullPath;
|
|
91
|
+
if (!fullPath) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
const testFilePath = path.isAbsolute(fullPath)
|
|
95
|
+
? fullPath
|
|
96
|
+
: path.join(process.cwd(), fullPath);
|
|
97
|
+
return (0, parse_test_steps_1.parsePlannedStepsFromFile)(testFilePath, test.testTitle);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Об'єднує виконані та невиконані кроки
|
|
101
|
+
*/
|
|
102
|
+
function combineSteps(executedSteps, plannedSteps) {
|
|
103
|
+
const executedStepTitles = executedSteps.map((step) => step.stepTitle);
|
|
104
|
+
const notExecutedSteps = plannedSteps.slice(executedStepTitles.length);
|
|
105
|
+
return [
|
|
106
|
+
...executedSteps,
|
|
107
|
+
...notExecutedSteps.map((stepTitle) => ({
|
|
108
|
+
stepTitle: stepTitle,
|
|
109
|
+
actualResult: [],
|
|
110
|
+
statusName: 'In Progress'
|
|
111
|
+
}))
|
|
112
|
+
];
|
|
113
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Парсить заплановані кроки тесту з файлу
|
|
3
|
+
* @param filePath - Шлях до файлу тесту
|
|
4
|
+
* @param testTitle - Назва тесту
|
|
5
|
+
* @returns Масив назв запланованих кроків
|
|
6
|
+
*/
|
|
7
|
+
export declare function parsePlannedStepsFromFile(filePath: string, testTitle: string): string[];
|
|
8
|
+
//# sourceMappingURL=parse-test-steps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-test-steps.d.ts","sourceRoot":"","sources":["../../utils/parse-test-steps.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CA4EvF"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.parsePlannedStepsFromFile = parsePlannedStepsFromFile;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
/**
|
|
39
|
+
* Парсить заплановані кроки тесту з файлу
|
|
40
|
+
* @param filePath - Шлях до файлу тесту
|
|
41
|
+
* @param testTitle - Назва тесту
|
|
42
|
+
* @returns Масив назв запланованих кроків
|
|
43
|
+
*/
|
|
44
|
+
function parsePlannedStepsFromFile(filePath, testTitle) {
|
|
45
|
+
const steps = [];
|
|
46
|
+
try {
|
|
47
|
+
// Перевіряємо, чи файл існує
|
|
48
|
+
if (!fs.existsSync(filePath)) {
|
|
49
|
+
return steps;
|
|
50
|
+
}
|
|
51
|
+
const src = fs.readFileSync(filePath, 'utf8');
|
|
52
|
+
const lines = src.split(/\r?\n/);
|
|
53
|
+
let currentTestTitle = null;
|
|
54
|
+
let insideTargetTest = false;
|
|
55
|
+
let braceCount = 0;
|
|
56
|
+
let testStartLine = -1;
|
|
57
|
+
// Регулярні вирази для пошуку тестів та кроків
|
|
58
|
+
const testTitleRegex = /\btest(\.only|\.skip|\.fixme)?\s*\(\s*(["'`])([^"'`]+)\2\s*,/;
|
|
59
|
+
const stepRegex = /\b(?:test|await\s+test)\.step\s*\(\s*(["'`])([^"'`]+)\1\s*,/;
|
|
60
|
+
for (let i = 0; i < lines.length; i++) {
|
|
61
|
+
const line = lines[i];
|
|
62
|
+
// Перевіряємо, чи це початок нового тесту
|
|
63
|
+
const testMatch = line.match(testTitleRegex);
|
|
64
|
+
if (testMatch) {
|
|
65
|
+
const foundTitle = testMatch[3];
|
|
66
|
+
// Якщо ми були всередині іншого тесту, скидаємо стан
|
|
67
|
+
if (insideTargetTest && foundTitle !== testTitle) {
|
|
68
|
+
insideTargetTest = false;
|
|
69
|
+
braceCount = 0;
|
|
70
|
+
}
|
|
71
|
+
if (foundTitle === testTitle) {
|
|
72
|
+
currentTestTitle = foundTitle;
|
|
73
|
+
insideTargetTest = true;
|
|
74
|
+
steps.length = 0;
|
|
75
|
+
testStartLine = i;
|
|
76
|
+
braceCount = 0;
|
|
77
|
+
// Починаємо рахувати відкриваючі дужки
|
|
78
|
+
const openBraces = (line.match(/\{/g) || []).length;
|
|
79
|
+
const closeBraces = (line.match(/\}/g) || []).length;
|
|
80
|
+
braceCount += openBraces - closeBraces;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
currentTestTitle = foundTitle;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Якщо ми знаходимось всередині потрібного тесту, шукаємо кроки
|
|
89
|
+
if (insideTargetTest && currentTestTitle === testTitle) {
|
|
90
|
+
// Рахуємо дужки для визначення меж тесту
|
|
91
|
+
const openBraces = (line.match(/\{/g) || []).length;
|
|
92
|
+
const closeBraces = (line.match(/\}/g) || []).length;
|
|
93
|
+
braceCount += openBraces - closeBraces;
|
|
94
|
+
// Якщо дужки закрилися, тест закінчився
|
|
95
|
+
if (braceCount <= 0 && i > testStartLine) {
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
const stepMatch = line.match(stepRegex);
|
|
99
|
+
if (stepMatch) {
|
|
100
|
+
steps.push(stepMatch[2]);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
// Мовчки ігноруємо помилки парсингу
|
|
107
|
+
console.error(`Помилка парсингу файлу ${filePath}:`, error);
|
|
108
|
+
}
|
|
109
|
+
return steps;
|
|
110
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saves test results to JSON file
|
|
3
|
+
*
|
|
4
|
+
* This function creates a JSON report from test results and saves it to the specified directory.
|
|
5
|
+
* If the directory doesn't exist, it will be created automatically.
|
|
6
|
+
*
|
|
7
|
+
* @param result - Object with test results to be saved
|
|
8
|
+
* @param outputDir - Directory for saving (default 'test-results')
|
|
9
|
+
* @returns Full path to the saved JSON file
|
|
10
|
+
* @throws Error if file cannot be saved
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const filepath = saveTestResultsToJson(testResults);
|
|
14
|
+
* console.log(`Saved to: ${filepath}`);
|
|
15
|
+
*/
|
|
16
|
+
export declare function saveTestResultsToJson(result: any, outputDir?: string): string;
|
|
17
|
+
//# sourceMappingURL=save-json-report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-json-report.d.ts","sourceRoot":"","sources":["../../utils/save-json-report.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,GAAE,MAAuB,GAAG,MAAM,CAyB7F"}
|