Skip to content

native esm autotest runtime - #278

Open
ArtMathArt wants to merge 8 commits into
masterfrom
WAT-277-native-esm-autotest-runtime
Open

native esm autotest runtime#278
ArtMathArt wants to merge 8 commits into
masterfrom
WAT-277-native-esm-autotest-runtime

Conversation

@ArtMathArt

Copy link
Copy Markdown
Collaborator

No description provided.

sukhinin-artem and others added 8 commits August 13, 2026 11:30
Deletes @testring/plugin-babel and @testring/sandbox entirely — nothing
in the execution path reaches them anymore. Test files are now expected
to run as native ESM directly, which needs a modern-enough Node (raised
via .nvmrc/engines here) and no longer needs a per-run Babel transform
or a vm.Script/vm.createContext execution context.

e2e-test-app's own selenium/coverage configs and dependency list drop
the babel plugin wiring accordingly.
Replaces the deleted vm-sandbox's execution path with native `import()`
in worker-controller.ts, for both forked and local-mode workers.
Adds two pieces native ESM needs that a vm-sandbox's custom require()
used to provide for free, via a real (not inlined data: URL) module
customization hooks file:
  - extensionless relative import resolution (`./helper` without `.js`)
Deliberately does NOT force-parse ambiguous `.js` files as ES modules:
Node's own module-syntax detection (`detect-module`, default since
20.19.0) already does this, and an earlier version of this hook that
tried to force it manually was the direct cause of a bug where a
dependency's own internal CommonJS file (chai's index.mjs -> ./index.js)
got incorrectly parsed as ESM. Not overriding format at all avoids that
class of bug structurally.

Also, on top of the execution-model change:
  - workerID now rotates after kill(), so a recycled worker's identity
    changes with it instead of staying fixed for the TestWorkerInstance's
    whole lifetime.
  - Threads a workerId field through ITestExecutionMessage /
    ITestExecutionCompleteMessage end to end, so every reported result
    (pass or fail) carries the worker that actually ran it.
  - TestWorkerLocal registers the same loader hooks a forked worker gets
    via worker/index.ts's bootstrap — it runs in-process and was
    silently missing them, which broke workerLimit: 'local' runs using
    extensionless imports.

New/adjusted fixtures cover: accurate stack traces through the native
path (stack-trace-accuracy.spec.ts), workerId presence and stability
across executions, and workerID changing after a real kill()+respawn.
restartWorker was boolean; every current value (true/false/'always')
keeps its exact existing behavior. Now also accepts an integer N,
recycling a worker's child process after every N executions instead of
either "never" or "every single test". 0 and 1 are both treated as
"every test", matching true/'always'.

Validated at config-load time (core/cli-config), not at first dispatch:
a negative or non-integer value fails fast with a clear error naming
the offending value, rather than being silently coerced.

test-run-controller.ts's per-worker recycle loop now counts executions
against the configured threshold instead of a single truthy check.
Demonstrates that a dependency previously pinned to a CommonJS-only
major purely for compatibility with the old execution model can now
move to its current, ESM-only release. file-resolver.ts's single call
site lazily loads it via a string-wrapped dynamic import() (the same
technique worker-controller.ts uses for native ESM test files), since
this package's own tsconfig still targets CommonJS output and can't
require() an ESM-only module directly.
upload.spec.js and save-pdf.spec.js used bare __dirname, which the
deleted vm-sandbox used to inject but is genuinely undefined under
native ESM. Fixed with the standard path.dirname(fileURLToPath(
import.meta.url)) replacement.

stack-trace-demo.spec.js is a real-browser-session regression guard for
FR-002/SC-002: deliberately throws at a known line and asserts the
reported stack's top frame names the exact file/line, proving the
guarantee holds through the full CLI -> worker -> native import() path
(not just the worker in isolation, which core/test-worker's own
stack-trace-accuracy.spec.ts already covers).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants