@activate-core/test-forge 2.3.0 → 2.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@activate-core/test-forge",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
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": {
@@ -10,9 +10,8 @@
10
10
  * const { need } = require('@activate-core/test-forge/reporters/interface.cjs');
11
11
  * const ORDER_SUMMARY = need('order summary URL');
12
12
  *
13
- * `testforge run` holds back a file while one of its names is blank, and
14
- * lists the names it waits for. Run anyway (--all), a blank name fails the
15
- * test with what to fill, never with a guess.
13
+ * A blank name fails each test that needs it with what to fill, never with a
14
+ * guess; the reporters file it as "Waiting for the product".
16
15
  */
17
16
  const fs = require('fs');
18
17
  const path = require('path');
@@ -36,12 +35,37 @@ function values() {
36
35
  return cache;
37
36
  }
38
37
 
38
+ /**
39
+ * While a test file loads (need() at its top, outside any test), a throw would
40
+ * fail the whole file and none of its tests would be reported. Instead each of
41
+ * its tests fails with the waiting error, from a beforeEach. Inside a running
42
+ * test the caller throws as usual.
43
+ */
44
+ function inRunningTest() {
45
+ try { if (globalThis.expect && globalThis.expect.getState().currentTestName) return true; } catch { /* not Jest */ }
46
+ try { require('@playwright/test').test.info(); return true; } catch { return false; } // throws outside a test
47
+ }
48
+
49
+ function failTestsOfThisFile(message) {
50
+ if (inRunningTest()) return false;
51
+ const hook = () => { throw new Error(message); };
52
+ try {
53
+ if (typeof globalThis.beforeEach === 'function') { globalThis.beforeEach(hook); return true; } // Jest
54
+ require('@playwright/test').test.beforeEach(hook); // Playwright
55
+ return true;
56
+ } catch {
57
+ return false;
58
+ }
59
+ }
60
+
39
61
  /** The product's value for `name`, or an error naming what to fill. */
40
62
  function need(name) {
41
63
  const v = values()[name];
42
64
  if (typeof v === 'string' ? v.trim() : v !== undefined && v !== null) return v;
43
65
  // The prefix lets the reporters file this as "waiting for the product", not as a defect.
44
- throw new Error(`[testforge:waiting] "${name}" is not in the product yet (blank in testforge/interface.json): this test runs for real once it is there.`);
66
+ const message = `[testforge:waiting] "${name}" is not in the product yet (blank in testforge/interface.json): this test runs for real once it is there.`;
67
+ if (failTestsOfThisFile(message)) return `<waiting: ${name}>`;
68
+ throw new Error(message);
45
69
  }
46
70
 
47
71
  module.exports = { need };