@activate-core/test-forge 2.5.0 → 2.7.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.
@@ -1,13 +1,14 @@
1
1
  // TestForge Jest reporter — auto-publishes the run to the dashboard on completion.
2
2
  // Add to jest.config.js:
3
3
  // reporters: ['default', ['<abs>/reporters/jest-reporter.cjs', { category: 'api' }]]
4
- const { cleanError, sig, publish, testChecks, expectation, failureDetail, findRoot, suiteName, testRoot, reviewVerdicts, notTheProduct, plainTitle } = require('./_shared.cjs');
4
+ const { cleanError, sig, publish, testChecks, expectation, failureDetail, findRoot, suiteName, testRoot, reviewVerdicts, notTheProduct, plainTitle, recordPassed, recordSummary } = require('./_shared.cjs');
5
5
 
6
6
  module.exports = class TestForgeJestReporter {
7
7
  constructor(_globalConfig, options) {
8
8
  this.category = (options && options.category) || 'api';
9
9
  this.testRoot = testRoot(findRoot(process.cwd()), this.category);
10
- this.verdictOf = reviewVerdicts(findRoot(process.cwd()));
10
+ this.root = findRoot(process.cwd());
11
+ this.verdictOf = reviewVerdicts(this.root);
11
12
  }
12
13
  async onRunComplete(_contexts, results) {
13
14
  const suites = {};
@@ -31,12 +32,15 @@ module.exports = class TestForgeJestReporter {
31
32
  checks: testChecks(f.testFilePath, a.location && a.location.line),
32
33
  ...(status === 'failed' ? expectation(raw) : {}),
33
34
  detail: status === 'failed' ? failureDetail(raw, { file: f.testFilePath, line: a.location && a.location.line }) : undefined,
34
- ...(status === 'failed' ? this.verdictOf(f.testFilePath, a.fullName || a.title) : {}),
35
+ ...(status === 'failed' ? this.verdictOf(f.testFilePath, a.fullName || a.title, raw) : {}),
35
36
  });
36
37
  }
37
38
  }
39
+ recordPassed(this.root, (results.testResults || []).flatMap((f) =>
40
+ (f.testResults || f.assertionResults || []).filter((a) => a.status === 'passed').map((a) => ({ file: f.testFilePath, title: a.title }))));
38
41
  const durationSec = Math.round((results.startTime ? Date.now() - results.startTime : 0) / 1000);
39
42
  const list = Object.values(suites);
43
+ recordSummary(this.root, this.category, list);
40
44
  // Same reasoning as the Playwright reporter: no suites means nothing ran,
41
45
  // and a published 0/0/0 run reads as a clean result.
42
46
  if (!list.length) {
@@ -1,12 +1,13 @@
1
1
  // TestForge Playwright reporter — auto-publishes the run to the dashboard on completion.
2
2
  // Add to playwright.config.js reporter array:
3
3
  // ['<abs>/reporters/playwright-reporter.cjs', { category: 'web' }]
4
- const { cleanError, sig, publish, testChecks, failureDetail, findRoot, suiteName, testRoot, reviewVerdicts, notTheProduct, plainTitle } = require('./_shared.cjs');
4
+ const { cleanError, sig, publish, testChecks, failureDetail, findRoot, suiteName, testRoot, reviewVerdicts, notTheProduct, plainTitle, recordPassed, recordSummary } = require('./_shared.cjs');
5
5
 
6
6
  module.exports = class TestForgePlaywrightReporter {
7
7
  constructor(options) {
8
8
  this.category = (options && options.category) || 'web';
9
9
  this.suites = {};
10
+ this.passed = [];
10
11
  this.start = Date.now();
11
12
  this.root = findRoot(process.cwd());
12
13
  this.testRoot = testRoot(this.root, this.category);
@@ -41,6 +42,7 @@ module.exports = class TestForgePlaywrightReporter {
41
42
  const status = result.status === 'passed' ? 'passed' : result.status === 'skipped' || notProduct ? 'skipped' : 'failed';
42
43
  const pend = (result.annotations || []).concat(test.annotations || []).filter((x) => x.type === 'skip' || x.type === 'fixme');
43
44
  const skipAnno = pend.find((x) => x.description) || pend[0];
45
+ if (status === 'passed') this.passed.push({ file, title: test.title });
44
46
  su.tests.push({
45
47
  name: plainTitle(test.title),
46
48
  status,
@@ -50,7 +52,7 @@ module.exports = class TestForgePlaywrightReporter {
50
52
  checks: ((test.annotations || []).find((x) => x.type === 'description') || {}).description
51
53
  || testChecks(test.location && test.location.file, test.location && test.location.line),
52
54
  ...(status === 'failed' ? this.failed(test, result) : {}),
53
- ...(status === 'failed' ? this.verdictOf(test.location && test.location.file, test.title) : {}),
55
+ ...(status === 'failed' ? this.verdictOf(test.location && test.location.file, test.title, raw) : {}),
54
56
  });
55
57
  }
56
58
  failed(test, result) {
@@ -63,7 +65,9 @@ module.exports = class TestForgePlaywrightReporter {
63
65
  }
64
66
  async onEnd(result) {
65
67
  const durationSec = Math.round(((result && result.duration) || (Date.now() - this.start)) / 1000);
68
+ recordPassed(this.root, this.passed);
66
69
  const suites = Object.values(this.suites);
70
+ recordSummary(this.root, this.category, suites);
67
71
  // A run that collected no suites did not test anything: global setup failed,
68
72
  // or the filter matched nothing. Publishing it records a 0/0/0 result that
69
73
  // reads as "the suite ran and found nothing wrong" — the most misleading
@@ -19,8 +19,13 @@ function runId() {
19
19
  }
20
20
 
21
21
  /** A value no other run produces: label + the run id's last 6 characters (letters and digits only). */
22
+ const uses = new Map();
22
23
  function unique(label = '') {
23
- return `${label}${runId().slice(-6)}`;
24
+ // The same label asked for again in one test file gets a new value: two
25
+ // rows built from one label (an email, a name) must not collide.
26
+ const n = (uses.get(label) || 0) + 1;
27
+ uses.set(label, n);
28
+ return `${label}${runId().slice(-6)}${n > 1 ? n : ''}`;
24
29
  }
25
30
 
26
31
  /**