@activate-core/test-forge 1.2.1 → 1.2.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.
package/dist/core/run/report.js
CHANGED
|
@@ -69,7 +69,7 @@ export function mapPlaywright(json, category = 'web') {
|
|
|
69
69
|
const rootDir = (json.config && json.config.rootDir) || process.cwd();
|
|
70
70
|
const walk = (suite) => {
|
|
71
71
|
for (const spec of suite.specs || []) {
|
|
72
|
-
const name =
|
|
72
|
+
const name = shared.suiteName(spec.file || suite.file || 'suite');
|
|
73
73
|
const su = (suites[name] ||= { name, category, tests: [] });
|
|
74
74
|
for (const t of spec.tests || []) {
|
|
75
75
|
const r = (t.results || [])[(t.results || []).length - 1] || {};
|
|
@@ -106,12 +106,10 @@ export function mapPlaywright(json, category = 'web') {
|
|
|
106
106
|
return { suites: Object.values(suites), durationSec: Math.round(((json.stats && json.stats.duration) || 0) / 1000) };
|
|
107
107
|
}
|
|
108
108
|
/** Map a Jest `--json` report to the dashboard run contract. */
|
|
109
|
-
export function mapJest(json, category = 'api') {
|
|
109
|
+
export function mapJest(json, category = 'api', testDir) {
|
|
110
110
|
const suites = {};
|
|
111
111
|
for (const f of json.testResults || []) {
|
|
112
|
-
const name =
|
|
113
|
-
.split('/').pop()
|
|
114
|
-
.replace(/\.(test|spec)\.[jt]s$/, '');
|
|
112
|
+
const name = shared.suiteName(f.name || f.testFilePath || 'suite', testDir);
|
|
115
113
|
const su = (suites[name] ||= { name, category, tests: [] });
|
|
116
114
|
for (const a of f.assertionResults || []) {
|
|
117
115
|
const status = a.status === 'passed' ? 'passed' : a.status === 'failed' ? 'failed' : 'skipped';
|
|
@@ -132,7 +130,7 @@ export async function publishReport(opts) {
|
|
|
132
130
|
const json = JSON.parse(fs.readFileSync(opts.resultsPath, 'utf8'));
|
|
133
131
|
// Jest's report has testResults; Playwright's has suites.
|
|
134
132
|
const { suites, durationSec } = Array.isArray(json.testResults)
|
|
135
|
-
? mapJest(json, opts.category || 'api')
|
|
133
|
+
? mapJest(json, opts.category || 'api', shared.testRoot(shared.findRoot(process.cwd()), opts.category || 'api'))
|
|
136
134
|
: mapPlaywright(json, opts.category || 'web');
|
|
137
135
|
const body = { project: opts.project, env: opts.env || process.env.TESTFORGE_ENV || 'local', durationSec, suites };
|
|
138
136
|
const res = await fetch(opts.dashboardUrl.replace(/\/$/, '') + '/api/v1/runs', {
|
|
@@ -196,7 +194,7 @@ function attachPending(dir, ext, suites) {
|
|
|
196
194
|
}
|
|
197
195
|
const byName = new Map();
|
|
198
196
|
for (const f of files)
|
|
199
|
-
byName.set(suiteName(f), f);
|
|
197
|
+
byName.set(suiteName(f, dir), f);
|
|
200
198
|
for (const s of suites) {
|
|
201
199
|
const f = byName.get(s.name);
|
|
202
200
|
if (!f || s.pending)
|
|
@@ -215,14 +213,14 @@ function walk(dir, ext, out) {
|
|
|
215
213
|
out.push(full);
|
|
216
214
|
}
|
|
217
215
|
}
|
|
218
|
-
const suiteName = (file) =>
|
|
216
|
+
const suiteName = (file, dir) => shared.suiteName(file, dir);
|
|
219
217
|
const staticCount = (file) => (fs.readFileSync(file, 'utf8').match(/\b(it|test)\s*\(/g) || []).length;
|
|
220
218
|
/** Static fallback: count `it(`/`test(` occurrences per file (undercounts parameterized tests). */
|
|
221
219
|
function jestStatic(dir, ext, category, out) {
|
|
222
220
|
const files = [];
|
|
223
221
|
walk(dir, ext, files);
|
|
224
222
|
for (const f of files)
|
|
225
|
-
out.push({ name: suiteName(f), category, total: staticCount(f) });
|
|
223
|
+
out.push({ name: suiteName(f, dir), category, total: staticCount(f) });
|
|
226
224
|
}
|
|
227
225
|
// setupFilesAfterEnv shim: runs after jest installs the test globals, replaces
|
|
228
226
|
// every test BODY and before/after hook with a no-op. Collection still runs
|
|
@@ -291,13 +289,13 @@ function jestCount(dir, ext, category, out) {
|
|
|
291
289
|
const j = JSON.parse(fs.readFileSync(outJson, 'utf8'));
|
|
292
290
|
const seen = new Set();
|
|
293
291
|
for (const f of j.testResults || []) {
|
|
294
|
-
const n = suiteName(String(f.name || f.testFilePath || 'suite'));
|
|
292
|
+
const n = suiteName(String(f.name || f.testFilePath || 'suite'), dir);
|
|
295
293
|
seen.add(n);
|
|
296
294
|
out.push({ name: n, category, total: (f.assertionResults || []).length });
|
|
297
295
|
}
|
|
298
296
|
// any file jest couldn't even load → static, and say so loudly
|
|
299
297
|
for (const f of files) {
|
|
300
|
-
const n = suiteName(f);
|
|
298
|
+
const n = suiteName(f, dir);
|
|
301
299
|
if (seen.has(n))
|
|
302
300
|
continue;
|
|
303
301
|
const total = staticCount(f);
|
|
@@ -324,7 +322,7 @@ function jestCount(dir, ext, category, out) {
|
|
|
324
322
|
* EXPANDS parameterized tests (loops / .each), so we get the real case count
|
|
325
323
|
* per file. Returns false if it couldn't run (caller falls back to static).
|
|
326
324
|
*/
|
|
327
|
-
function playwrightList(pkgDir, category, out) {
|
|
325
|
+
function playwrightList(pkgDir, dir, category, out) {
|
|
328
326
|
try {
|
|
329
327
|
// `--reporter=list` so the project's own reporters — ours included — do
|
|
330
328
|
// not run during a count. Listing publishes nothing on its own, but a
|
|
@@ -335,10 +333,12 @@ function playwrightList(pkgDir, category, out) {
|
|
|
335
333
|
const counts = {};
|
|
336
334
|
for (const line of res.split('\n')) {
|
|
337
335
|
const m = line.match(/([^\s›»]+\.(?:test|spec)\.[jt]sx?):\d+:\d+/);
|
|
338
|
-
if (m)
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
336
|
+
if (!m)
|
|
337
|
+
continue;
|
|
338
|
+
// Playwright lists files relative to testDir; older versions relative to the config dir.
|
|
339
|
+
const abs = [path.resolve(dir, m[1]), path.resolve(pkgDir, m[1])].find((f) => fs.existsSync(f)) ?? path.resolve(dir, m[1]);
|
|
340
|
+
const n = suiteName(abs, dir);
|
|
341
|
+
counts[n] = (counts[n] || 0) + 1;
|
|
342
342
|
}
|
|
343
343
|
const names = Object.keys(counts);
|
|
344
344
|
if (!names.length)
|
|
@@ -365,7 +365,7 @@ export function scanInventory(cwd, testOutput, ext, framework = {}) {
|
|
|
365
365
|
if (framework[category] === 'playwright') {
|
|
366
366
|
// The config sits at the package root (or, beside a project's own
|
|
367
367
|
// config, in the tests' parent folder) — list from wherever it is.
|
|
368
|
-
if (playwrightList(packageRoot(dir), category, suites) || playwrightList(path.dirname(dir), category, suites)) {
|
|
368
|
+
if (playwrightList(packageRoot(dir), dir, category, suites) || playwrightList(path.dirname(dir), dir, category, suites)) {
|
|
369
369
|
attachPending(dir, ext, suites);
|
|
370
370
|
continue;
|
|
371
371
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activate-core/test-forge",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "AI-powered QA automation. Scans a project, drafts journey docs, and generates seeded Jest/Playwright tests. Works in any project, with any AI CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/reporters/_shared.cjs
CHANGED
|
@@ -352,4 +352,25 @@ async function publish(category, suites, durationSec) {
|
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
|
|
355
|
+
// A suite is named by its path under the test root — "booking-summary/keyboard-access" —
|
|
356
|
+
// because several journeys may each own a keyboard-access.test.ts. Keyed by basename
|
|
357
|
+
// alone, three such files became one suite of 22 and a single-journey run showed 13
|
|
358
|
+
// phantom skips. A relative path is kept as given (Playwright's JSON already reports
|
|
359
|
+
// spec files relative to testDir); an absolute path outside the root falls back to the
|
|
360
|
+
// bare file name.
|
|
361
|
+
function suiteName(file, root) {
|
|
362
|
+
let rel = String(file || 'suite').replace(/\\/g, '/');
|
|
363
|
+
if (path.isAbsolute(rel)) {
|
|
364
|
+
const r = root ? path.relative(root, rel).replace(/\\/g, '/') : '';
|
|
365
|
+
rel = r && !r.startsWith('..') ? r : rel.split('/').pop();
|
|
366
|
+
}
|
|
367
|
+
return rel.replace(/\.(test|spec)\.[jt]sx?$/, '');
|
|
368
|
+
}
|
|
369
|
+
// The configured test folder for a category (testOutput in testforge.config.json), absolute.
|
|
370
|
+
function testRoot(root, category) {
|
|
371
|
+
const out = loadConfig(root).testOutput;
|
|
372
|
+
const d = out && out[category];
|
|
373
|
+
return d ? path.resolve(root, d) : undefined;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
module.exports = { strip, cleanError, sig, publish, gitInfo, resolveEnv, testChecks, expectation, failureDetail, findRoot, suiteName, testRoot };
|
|
@@ -1,16 +1,17 @@
|
|
|
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 } = require('./_shared.cjs');
|
|
4
|
+
const { cleanError, sig, publish, testChecks, expectation, failureDetail, findRoot, suiteName, testRoot } = 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
|
+
this.testRoot = testRoot(findRoot(process.cwd()), this.category);
|
|
9
10
|
}
|
|
10
11
|
async onRunComplete(_contexts, results) {
|
|
11
12
|
const suites = {};
|
|
12
13
|
for (const f of results.testResults || []) {
|
|
13
|
-
const name =
|
|
14
|
+
const name = suiteName(f.testFilePath || f.name || 'suite', this.testRoot);
|
|
14
15
|
const su = suites[name] || (suites[name] = { name, category: this.category, tests: [] });
|
|
15
16
|
for (const a of (f.testResults || f.assertionResults || [])) {
|
|
16
17
|
const status = a.status === 'passed' ? 'passed' : a.status === 'failed' ? 'failed' : 'skipped';
|
|
@@ -1,7 +1,7 @@
|
|
|
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 } = require('./_shared.cjs');
|
|
4
|
+
const { cleanError, sig, publish, testChecks, failureDetail, findRoot, suiteName, testRoot } = require('./_shared.cjs');
|
|
5
5
|
|
|
6
6
|
module.exports = class TestForgePlaywrightReporter {
|
|
7
7
|
constructor(options) {
|
|
@@ -9,6 +9,12 @@ module.exports = class TestForgePlaywrightReporter {
|
|
|
9
9
|
this.suites = {};
|
|
10
10
|
this.start = Date.now();
|
|
11
11
|
this.root = findRoot(process.cwd());
|
|
12
|
+
this.testRoot = testRoot(this.root, this.category);
|
|
13
|
+
}
|
|
14
|
+
onBegin(config) {
|
|
15
|
+
// Playwright's own testDir is the authority when it has one.
|
|
16
|
+
const td = config && config.projects && config.projects[0] && config.projects[0].testDir;
|
|
17
|
+
if (td) this.testRoot = td;
|
|
12
18
|
}
|
|
13
19
|
// Everything the runner knows about a failure beyond its message: where it
|
|
14
20
|
// happened, the browser, the test's timeout and the artifacts it left.
|
|
@@ -26,7 +32,7 @@ module.exports = class TestForgePlaywrightReporter {
|
|
|
26
32
|
}
|
|
27
33
|
onTestEnd(test, result) {
|
|
28
34
|
const file = (test.location && test.location.file) || 'suite';
|
|
29
|
-
const name =
|
|
35
|
+
const name = suiteName(file, this.testRoot);
|
|
30
36
|
const su = this.suites[name] || (this.suites[name] = { name, category: this.category, tests: [] });
|
|
31
37
|
const status = result.status === 'passed' ? 'passed' : result.status === 'skipped' ? 'skipped' : 'failed';
|
|
32
38
|
const raw = result.error && result.error.message;
|