@flash-ai-team/flash-test-framework 0.0.2 → 0.0.3
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/core/TestBase.js
CHANGED
|
@@ -3,11 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.expect = exports.test = void 0;
|
|
4
4
|
const test_1 = require("@playwright/test");
|
|
5
5
|
const Keyword_1 = require("./Keyword");
|
|
6
|
+
const ReporterUtils_1 = require("../reporting/ReporterUtils");
|
|
6
7
|
exports.test = test_1.test.extend({
|
|
7
8
|
contextSetup: [async ({ page }, use, testInfo) => {
|
|
8
9
|
// Initialize the Keyword Context before every test
|
|
9
10
|
Keyword_1.KeywordContext.page = page;
|
|
10
11
|
Keyword_1.KeywordContext.testInfo = testInfo;
|
|
12
|
+
// Ensure report folder exists automatically
|
|
13
|
+
(0, ReporterUtils_1.ensureReportFolder)(testInfo);
|
|
11
14
|
await use();
|
|
12
15
|
}, { auto: true }],
|
|
13
16
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { Suite } from '@playwright/test/reporter';
|
|
2
2
|
export declare function getReportFolder(suite: Suite): string;
|
|
3
|
+
import { TestInfo } from '@playwright/test';
|
|
4
|
+
export declare function ensureReportFolder(testInfo: TestInfo): string;
|
|
3
5
|
export declare function resetReportFolderCache(): void;
|
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.getReportFolder = getReportFolder;
|
|
37
|
+
exports.ensureReportFolder = ensureReportFolder;
|
|
37
38
|
exports.resetReportFolderCache = resetReportFolderCache;
|
|
38
39
|
const fs = __importStar(require("fs"));
|
|
39
40
|
const path = __importStar(require("path"));
|
|
@@ -64,6 +65,28 @@ function getReportFolder(suite) {
|
|
|
64
65
|
console.log(`[ReporterUtils] Calculated report folder: ${cachedReportFolder}`);
|
|
65
66
|
return cachedReportFolder;
|
|
66
67
|
}
|
|
68
|
+
// ... existing code ...
|
|
69
|
+
function ensureReportFolder(testInfo) {
|
|
70
|
+
if (cachedReportFolder) {
|
|
71
|
+
return cachedReportFolder;
|
|
72
|
+
}
|
|
73
|
+
const timestamp = new Date().toISOString().replace(/T/, '_').replace(/:/g, '').split('.')[0];
|
|
74
|
+
// Extract suite name from test info title path (usually file name without ext)
|
|
75
|
+
// testInfo.titlePath[0] is usually the file name relative to test dir, e.g. "suites/SauceDemoAI.spec.ts"
|
|
76
|
+
let suiteName = 'TestRun';
|
|
77
|
+
if (testInfo.titlePath.length > 0) {
|
|
78
|
+
const fileName = path.basename(testInfo.file || '');
|
|
79
|
+
if (fileName) {
|
|
80
|
+
suiteName = fileName.split('.')[0];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
cachedReportFolder = path.join(process.cwd(), 'reports', suiteName, `test_${timestamp}`);
|
|
84
|
+
if (!fs.existsSync(cachedReportFolder)) {
|
|
85
|
+
fs.mkdirSync(cachedReportFolder, { recursive: true });
|
|
86
|
+
}
|
|
87
|
+
console.log(`[ReporterUtils] AUTO-CREATED report folder: ${cachedReportFolder}`);
|
|
88
|
+
return cachedReportFolder;
|
|
89
|
+
}
|
|
67
90
|
function resetReportFolderCache() {
|
|
68
91
|
cachedReportFolder = null;
|
|
69
92
|
}
|