@testsmith/testblocks 0.8.8 → 0.9.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/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.8.8',
450
+ '@testsmith/testblocks': '^0.9.0',
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, '&lt;')
26
34
  .replace(/>/g, '&gt;')
@@ -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, '&amp;')
36
44
  .replace(/</g, '&lt;')
37
45
  .replace(/>/g, '&gt;')