@testomatio/reporter 2.5.0 → 2.5.2

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.
@@ -43,8 +43,7 @@ class JestReporter {
43
43
  let steps;
44
44
  const { status, title, duration, failureMessages } = result;
45
45
  if (failureMessages[0]) {
46
- let errorMessage = failureMessages[0].replace((0, utils_js_1.ansiRegExp)(), '');
47
- errorMessage = errorMessage.split('\n')[0];
46
+ const errorMessage = failureMessages[0].replace((0, utils_js_1.ansiRegExp)(), '');
48
47
  error = new Error(errorMessage);
49
48
  steps = failureMessages[0];
50
49
  }
@@ -12,9 +12,10 @@ declare class PlaywrightReporter {
12
12
  #private;
13
13
  }
14
14
  /**
15
- * Extracts and normalizes tags from test title, test options, and suite level
15
+ * Extracts tags from test title, test options, and suite level
16
+ * Identifies duplicate tags (case-insensitive)
16
17
  * @param {*} test - testInfo object from Playwright
17
- * @returns {string[]} - array of normalized tags
18
+ * @returns {string[]} - array of normalized tags with @ prefix
18
19
  */
19
20
  export function extractTags(test: any): string[];
20
21
  import TestomatioClient from '../client.js';
@@ -92,7 +92,7 @@ class PlaywrightReporter {
92
92
  test_id: (0, utils_js_1.getTestomatIdFromTestTitle)(`${title} ${tags.join(' ')}`),
93
93
  suite_title,
94
94
  title,
95
- tags,
95
+ tags: tags.map(tag => tag.replace('@', '')),
96
96
  steps: steps.length ? steps : undefined,
97
97
  time: duration,
98
98
  logs,
@@ -223,27 +223,33 @@ function generateTmpFilepath(filename = '') {
223
223
  return path_1.default.join(tmpdir, filename);
224
224
  }
225
225
  /**
226
- * Extracts and normalizes tags from test title, test options, and suite level
226
+ * Extracts tags from test title, test options, and suite level
227
+ * Identifies duplicate tags (case-insensitive)
227
228
  * @param {*} test - testInfo object from Playwright
228
- * @returns {string[]} - array of normalized tags
229
+ * @returns {string[]} - array of normalized tags with @ prefix
229
230
  */
230
231
  function extractTags(test) {
231
- const tagsSet = new Set();
232
- // Extract tags from test title (@tag format)
233
- const titleTagsMatch = test.title.match(/@\w+/g);
234
- if (titleTagsMatch) {
235
- titleTagsMatch.forEach(tag => {
236
- tagsSet.add(tag.replace('@', '').toLowerCase());
237
- });
232
+ const tagsMap = new Map(); // key: lowercase tag, value: original case tag
233
+ function addTag(tag) {
234
+ if (typeof tag !== 'string')
235
+ return;
236
+ const trimmed = tag.trim();
237
+ if (!trimmed)
238
+ return;
239
+ const normalizedTag = trimmed.startsWith('@') ? trimmed : `@${trimmed}`;
240
+ const lowercaseTag = normalizedTag.toLowerCase();
241
+ if (!tagsMap.has(lowercaseTag)) {
242
+ tagsMap.set(lowercaseTag, normalizedTag);
243
+ }
238
244
  }
239
- // Extract tags from test.tags (Playwright built-in tags)
240
- if (test.tags && Array.isArray(test.tags)) {
241
- test.tags.forEach(tag => {
242
- const normalizedTag = typeof tag === 'string' ? tag.replace('@', '').toLowerCase() : String(tag).toLowerCase();
243
- tagsSet.add(normalizedTag);
244
- });
245
+ // Extract tags from test title (@tag format); only test title is considered
246
+ const titleTagsMatch = test.title.match(/@[A-Za-z0-9_-]+/g) || [];
247
+ titleTagsMatch.forEach(addTag);
248
+ // Extract tags from test.tags (Playwright built-in tags); ignore parents
249
+ if (Array.isArray(test.tags)) {
250
+ test.tags.forEach(addTag);
245
251
  }
246
- return Array.from(tagsSet);
252
+ return Array.from(tagsMap.values());
247
253
  }
248
254
  /**
249
255
  * Returns filename + test title
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "engines": {
6
6
  "node": ">=18"
@@ -44,8 +44,7 @@ export class JestReporter {
44
44
  let steps;
45
45
  const { status, title, duration, failureMessages } = result;
46
46
  if (failureMessages[0]) {
47
- let errorMessage = failureMessages[0].replace(ansiRegExp(), '');
48
- errorMessage = errorMessage.split('\n')[0];
47
+ const errorMessage = failureMessages[0].replace(ansiRegExp(), '');
49
48
  error = new Error(errorMessage);
50
49
  steps = failureMessages[0];
51
50
  }
@@ -96,7 +96,7 @@ class PlaywrightReporter {
96
96
  test_id: getTestomatIdFromTestTitle(`${title} ${tags.join(' ')}`),
97
97
  suite_title,
98
98
  title,
99
- tags,
99
+ tags: tags.map(tag => tag.replace('@', '')),
100
100
  steps: steps.length ? steps : undefined,
101
101
  time: duration,
102
102
  logs,
@@ -248,29 +248,35 @@ function generateTmpFilepath(filename = '') {
248
248
  }
249
249
 
250
250
  /**
251
- * Extracts and normalizes tags from test title, test options, and suite level
251
+ * Extracts tags from test title, test options, and suite level
252
+ * Identifies duplicate tags (case-insensitive)
252
253
  * @param {*} test - testInfo object from Playwright
253
- * @returns {string[]} - array of normalized tags
254
+ * @returns {string[]} - array of normalized tags with @ prefix
254
255
  */
255
256
  function extractTags(test) {
256
- const tagsSet = new Set();
257
-
258
- // Extract tags from test title (@tag format)
259
- const titleTagsMatch = test.title.match(/@\w+/g);
260
- if (titleTagsMatch) {
261
- titleTagsMatch.forEach(tag => {
262
- tagsSet.add(tag.replace('@', '').toLowerCase());
263
- });
257
+ const tagsMap = new Map(); // key: lowercase tag, value: original case tag
258
+
259
+ function addTag(tag) {
260
+ if (typeof tag !== 'string') return;
261
+ const trimmed = tag.trim();
262
+ if (!trimmed) return;
263
+ const normalizedTag = trimmed.startsWith('@') ? trimmed : `@${trimmed}`;
264
+ const lowercaseTag = normalizedTag.toLowerCase();
265
+ if (!tagsMap.has(lowercaseTag)) {
266
+ tagsMap.set(lowercaseTag, normalizedTag);
267
+ }
264
268
  }
265
269
 
266
- // Extract tags from test.tags (Playwright built-in tags)
267
- if (test.tags && Array.isArray(test.tags)) {
268
- test.tags.forEach(tag => {
269
- const normalizedTag = typeof tag === 'string' ? tag.replace('@', '').toLowerCase() : String(tag).toLowerCase();
270
- tagsSet.add(normalizedTag);
271
- });
270
+ // Extract tags from test title (@tag format); only test title is considered
271
+ const titleTagsMatch = test.title.match(/@[A-Za-z0-9_-]+/g) || [];
272
+ titleTagsMatch.forEach(addTag);
273
+
274
+ // Extract tags from test.tags (Playwright built-in tags); ignore parents
275
+ if (Array.isArray(test.tags)) {
276
+ test.tags.forEach(addTag);
272
277
  }
273
- return Array.from(tagsSet);
278
+
279
+ return Array.from(tagsMap.values());
274
280
  }
275
281
 
276
282
  /**