@testsmith/testblocks 0.8.9 → 0.9.1
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/cli/executor.js +28 -18
- package/dist/cli/index.js +1 -1
- package/dist/cli/reporters/utils.d.ts +4 -0
- package/dist/cli/reporters/utils.js +10 -2
- package/dist/client/assets/{index-DGmSW0q0.js → index-BCKY2YTp.js} +88 -88
- package/dist/client/assets/{index-DGmSW0q0.js.map → index-BCKY2YTp.js.map} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/core/blocks/playwright/interactions.js +39 -15
- package/dist/core/blocks/playwright/retrieval.js +18 -6
- package/dist/core/blocks/playwright/types.d.ts +43 -10
- package/dist/server/executor.js +27 -17
- package/package.json +1 -1
package/dist/cli/executor.js
CHANGED
|
@@ -93,29 +93,39 @@ class TestExecutor {
|
|
|
93
93
|
}
|
|
94
94
|
// Create base context for hooks
|
|
95
95
|
const baseContext = this.createBaseContext(testFile.variables);
|
|
96
|
+
// Check if there are any enabled tests
|
|
97
|
+
const enabledTests = testFile.tests.filter(t => !t.disabled);
|
|
98
|
+
const hasEnabledTests = enabledTests.length > 0;
|
|
99
|
+
// Add skipped results for disabled tests first
|
|
100
|
+
for (const test of testFile.tests) {
|
|
101
|
+
if (test.disabled) {
|
|
102
|
+
console.log(` Skipping (disabled): ${test.name}`);
|
|
103
|
+
results.push({
|
|
104
|
+
testId: test.id,
|
|
105
|
+
testName: test.name,
|
|
106
|
+
status: 'skipped',
|
|
107
|
+
duration: 0,
|
|
108
|
+
steps: [],
|
|
109
|
+
error: { message: 'Test is disabled' },
|
|
110
|
+
startedAt: new Date().toISOString(),
|
|
111
|
+
finishedAt: new Date().toISOString(),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Only run hooks and tests if there are enabled tests
|
|
116
|
+
if (!hasEnabledTests) {
|
|
117
|
+
console.log(' All tests disabled, skipping hooks');
|
|
118
|
+
await this.cleanup();
|
|
119
|
+
return results;
|
|
120
|
+
}
|
|
96
121
|
try {
|
|
97
122
|
// Run beforeAll hooks
|
|
98
123
|
if (testFile.beforeAll) {
|
|
99
124
|
const steps = this.extractStepsFromBlocklyState(testFile.beforeAll);
|
|
100
125
|
await this.runSteps(steps, baseContext, 'beforeAll');
|
|
101
126
|
}
|
|
102
|
-
// Run each test - pass baseContext variables so beforeAll state persists
|
|
103
|
-
for (const test of
|
|
104
|
-
// Skip disabled tests
|
|
105
|
-
if (test.disabled) {
|
|
106
|
-
console.log(` Skipping (disabled): ${test.name}`);
|
|
107
|
-
results.push({
|
|
108
|
-
testId: test.id,
|
|
109
|
-
testName: test.name,
|
|
110
|
-
status: 'skipped',
|
|
111
|
-
duration: 0,
|
|
112
|
-
steps: [],
|
|
113
|
-
error: { message: 'Test is disabled' },
|
|
114
|
-
startedAt: new Date().toISOString(),
|
|
115
|
-
finishedAt: new Date().toISOString(),
|
|
116
|
-
});
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
127
|
+
// Run each enabled test - pass baseContext variables so beforeAll state persists
|
|
128
|
+
for (const test of enabledTests) {
|
|
119
129
|
// Check if test has data-driven sets
|
|
120
130
|
if (test.data && test.data.length > 0) {
|
|
121
131
|
// Run test for each data set
|
|
@@ -563,7 +573,7 @@ class TestExecutor {
|
|
|
563
573
|
let screenshot;
|
|
564
574
|
if (status === 'failed' && this.page) {
|
|
565
575
|
try {
|
|
566
|
-
const buffer = await this.page.screenshot({ type: 'png' });
|
|
576
|
+
const buffer = await this.page.screenshot({ type: 'png', fullPage: true });
|
|
567
577
|
screenshot = `data:image/png;base64,${buffer.toString('base64')}`;
|
|
568
578
|
}
|
|
569
579
|
catch (screenshotError) {
|
package/dist/cli/index.js
CHANGED
|
@@ -447,7 +447,7 @@ program
|
|
|
447
447
|
'test:ci': 'testblocks run tests/**/*.testblocks.json -r console,html,junit -o reports',
|
|
448
448
|
},
|
|
449
449
|
devDependencies: {
|
|
450
|
-
'@testsmith/testblocks': '^0.
|
|
450
|
+
'@testsmith/testblocks': '^0.9.1',
|
|
451
451
|
},
|
|
452
452
|
};
|
|
453
453
|
fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2));
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* Generate timestamp string for filenames (e.g., 2024-01-15T14-30-45)
|
|
6
6
|
*/
|
|
7
7
|
export declare function getTimestamp(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Strip ANSI escape codes from a string
|
|
10
|
+
*/
|
|
11
|
+
export declare function stripAnsi(str: string): string;
|
|
8
12
|
/**
|
|
9
13
|
* Escape XML special characters
|
|
10
14
|
*/
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getTimestamp = getTimestamp;
|
|
7
|
+
exports.stripAnsi = stripAnsi;
|
|
7
8
|
exports.escapeXml = escapeXml;
|
|
8
9
|
exports.escapeHtml = escapeHtml;
|
|
9
10
|
exports.formatStepType = formatStepType;
|
|
@@ -16,11 +17,18 @@ exports.formatStepOutput = formatStepOutput;
|
|
|
16
17
|
function getTimestamp() {
|
|
17
18
|
return new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
18
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Strip ANSI escape codes from a string
|
|
22
|
+
*/
|
|
23
|
+
function stripAnsi(str) {
|
|
24
|
+
// eslint-disable-next-line no-control-regex
|
|
25
|
+
return str.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, '');
|
|
26
|
+
}
|
|
19
27
|
/**
|
|
20
28
|
* Escape XML special characters
|
|
21
29
|
*/
|
|
22
30
|
function escapeXml(str) {
|
|
23
|
-
return str
|
|
31
|
+
return stripAnsi(str)
|
|
24
32
|
.replace(/&/g, '&')
|
|
25
33
|
.replace(/</g, '<')
|
|
26
34
|
.replace(/>/g, '>')
|
|
@@ -31,7 +39,7 @@ function escapeXml(str) {
|
|
|
31
39
|
* Escape HTML special characters
|
|
32
40
|
*/
|
|
33
41
|
function escapeHtml(str) {
|
|
34
|
-
return str
|
|
42
|
+
return stripAnsi(str)
|
|
35
43
|
.replace(/&/g, '&')
|
|
36
44
|
.replace(/</g, '<')
|
|
37
45
|
.replace(/>/g, '>')
|