2026-08-11-cross-platform-npm-test-scripts.md 5.05 KB

Cross-Platform npm Test Scripts Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Make every npm test script use the same file discovery, execution order, and exit-code behavior on Windows and Unix-like shells.

Architecture: Use Node 20's native recursive directory support for directory-scoped suites. Keep the quotation suite narrow by listing its five files explicitly, and compose the root suite with named npm scripts joined by && so no shell-specific glob or background behavior remains.

Tech Stack: npm scripts, Node.js 20 built-in test runner, JSON.

Global Constraints

  • Do not add third-party dependencies.
  • Do not change test files, business code, or Node module-type configuration.
  • Preserve the intended directory scope of every named test suite.
  • Stop the root suite on the first non-zero child exit code.
  • Treat existing assertion, module-loading, or environment failures as out of scope; distinguish them from literal wildcard path failures.
  • This is a small script compatibility fix and does not require a migration manifest.

Task 1: Replace shell-dependent test discovery and orchestration

Files:

  • Modify: package.json:27-37
  • Reference: docs/designs/2026-08-11-cross-platform-npm-test-scripts-design.md

Interfaces:

  • Consumes: Node 20 node --test <directory> recursive discovery and the existing test directory layout.
  • Produces: Cross-platform test, test:tabIndex, test:equity, test:dynamicForm, test:createOrder, test:orderLifecycle, and test:quotation npm commands.

  • Step 1: Reproduce the Windows failures before editing

Run:

npm run test:quotation
npm run test:equity

Expected: both commands exit non-zero with Could not find; the reported path still contains * or ** literally.

  • Step 2: Replace all shell-expanded test paths and root command separators

Update the affected scripts entries in package.json to exactly:

{
  "test": "npm run test:createOrder && node --experimental-detect-module --test tests && npm run test:dynamicForm && npm run test:tabIndex && npm run test:equity",
  "test:tabIndex": "node --test tabIndex/tests",
  "test:equity": "node --experimental-detect-module --test packageEquity/tests",
  "test:dynamicForm": "node --test packageDynamicForm/tests",
  "test:createOrder": "node --experimental-detect-module --test tabWorkOrder/pages/createOrder/tests",
  "test:orderLifecycle": "node --experimental-detect-module --test tests/order-lifecycle",
  "test:quotation": "node --experimental-detect-module --test packageEquity/tests/quotationCustomerDailyFields.test.mjs packageEquity/tests/quotationCustomerDailyFields.ui.test.mjs packageEquity/tests/quotationMoney.helpers.test.mjs packageEquity/tests/quotationPayload.helpers.test.mjs packageEquity/tests/ruleFn.test.mjs"
}

Leave test:orderLifecycle:contract, test:orderLifecycle:preflight, test:orderLifecycle:e2e, test:orderLifecycle:ui, and test:components unchanged because they already use explicit paths.

  • Step 3: Validate JSON and prove the shell-dependent patterns are gone

Run:

node -e "JSON.parse(require('fs').readFileSync('package.json', 'utf8')); console.log('package.json valid')"
rg -n '\*\*|quotation\*\.test|(^|[^&])&([^&]|$)' package.json

Expected: JSON validation prints package.json valid; rg finds no matches in npm test scripts. The && operators are allowed and must remain.

  • Step 4: Verify the focused suites through their original npm entry points

Run each command separately so one result does not hide another:

npm run test:quotation
npm run test:equity
npm run test:createOrder
npm run test:tabIndex
npm run test:orderLifecycle

Expected: none reports Could not find with a literal wildcard. test:quotation, test:equity, test:createOrder, and test:tabIndex pass. test:orderLifecycle either passes/skips environment-gated live tests or reports a real test/environment failure without a wildcard path.

  • Step 5: Verify the dynamic-form and root-suite failure boundary

Run:

npm run test:dynamicForm
npm test

Expected: neither command reports a literal wildcard path. If the known packageDynamicForm ESM/CommonJS cycle remains, both commands may exit non-zero on that real module-loading failure; npm test must stop at test:dynamicForm and propagate its exit code instead of continuing silently.

  • Step 6: Review the final diff

Run:

git diff --check -- package.json
git diff -- package.json

Expected: no whitespace errors; only the seven intended npm script values changed, with no dependency or lock-file changes.

  • Step 7: Commit the compatibility fix
git add -- package.json
git commit -m "fix: make npm test scripts cross-platform"

Expected: the commit contains only package.json; all pre-existing business changes remain unstaged.