feat(quickjs): insomnia.test()/pm.test() lifecycle + real chai parity - #10410
Open
jackkav wants to merge 4 commits into
Open
feat(quickjs): insomnia.test()/pm.test() lifecycle + real chai parity#10410jackkav wants to merge 4 commits into
jackkav wants to merge 4 commits into
Conversation
Base automatically changed from
claude/quickjs-sendrequest-bridge-wip
to
develop
August 17, 2026 09:51
Vendors chai@4.5.0 through the existing M3 npm-vendoring pipeline (sandbox-vendored-libs-list.ts -> chai.generated.ts) and binds its .expect as insomnia.expect, so pm.test() assertion messages match the hidden-window path byte-for-byte instead of a hand-rolled reimplementation. insomnia.test()/insomnia.test.skip() run entirely inside the VM, building requestTestResults in the same shape run-script.ts produces; a pm.test() the script doesn't await is still waited on before the run ends. Also generalizes the sendRequest bridge's teardown fix into a BridgeCalls registry that drains outstanding calls after the task settles (bounded by the script deadline) -- landing PR2's deferred item so a fire-and-forget insomnia.sendRequest(url, callback) actually gets its callback called instead of being silently dropped, with anything still open at the deadline cancelled and rejected with a real, observable error.
jackkav
force-pushed
the
claude/quickjs-test-lifecycle
branch
from
August 17, 2026 10:08
cf74b09 to
797c000
Compare
A background formatter in this environment stripped the leading /* eslint-disable */ from the vendored chai bundle before it was committed, which the sandbox:vendored:ci guardrail in CI correctly flagged as drift from a fresh regeneration.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR advances the QuickJS scripting sandbox rollout by adding in-VM insomnia.test() lifecycle handling and switching assertions to real vendored chai to better match the existing (hidden-window) scripting path, while also improving the insomnia.sendRequest() bridge teardown/drain behavior.
Changes:
- Vendor
chai@4.5.0via the existing sandbox vendoring pipeline and exposeinsomnia.expectbacked by that bundle. - Implement
insomnia.test()/insomnia.test.skip()inside the QuickJS VM and exportrequestTestResultsin the same shape as the existing scripting environment. - Generalize sendRequest teardown into a
BridgeCallsregistry and drain pending calls after the task settles (bounded by deadline), cancelling leftovers at teardown.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/insomnia/src/templating/sandbox/vendored/uuid.generated.ts | Regenerated vendored uuid bundle metadata/header. |
| packages/insomnia/src/templating/sandbox/vendored/pkg/package.json | Add chai as an exact-pinned vendored dependency and update description to cover scripting sandbox too. |
| packages/insomnia/src/templating/sandbox/vendored/pkg/package-lock.json | Lockfile updates for vendored chai and its transitive dependencies. |
| packages/insomnia/src/templating/sandbox/vendored/chai.generated.ts | New generated vendored chai bundle source/version export. |
| packages/insomnia/src/templating/sandbox/vendored/ajv.generated.ts | Regenerated vendored ajv bundle metadata/header. |
| packages/insomnia/src/scripting/quickjs-script-engine.ts | Bind vendored chai into the VM, implement in-VM tests/results, and add BridgeCalls registry + drain/teardown semantics. |
| packages/insomnia/src/scripting/quickjs-script-engine.test.ts | Add coverage for QuickJS insomnia.test() behavior and new bridge drain/cancellation behaviors. |
| packages/insomnia/scripts/sandbox-vendored-libs-list.ts | Add chai to the vendored libs list (also used by QuickJS scripting engine). |
Files not reviewed (1)
- packages/insomnia/src/templating/sandbox/vendored/pkg/package-lock.json: Generated file
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Clarify doc comments: there is no globalThis.pm alias in the QuickJS sandbox, matching the hidden-window sandbox, which has none either (only `insomnia` and the `$` Postman-compat alias exist in both). Drop the `e &&` guard around e.actual/e.expected in the failed-test errorMessage so it matches insomnia-scripting-environment/src/objects/ test.ts's template exactly -- the guard changed the rendered value for a falsy thrown primitive (e.g. `throw 0`) instead of just avoiding a crash, which property access on a primitive never causes anyway.
Without this, ESLint's default reportUnusedDisableDirectives flags these checked-in, machine-generated files' blanket `/* eslint-disable */` as unused (the minified bundle happens to trip no rule under this config), and `--fix` deletes it -- which then perpetually conflicts with scripts/generate-sandbox-vendored.ts always re-adding it and with CI's sandbox:vendored:generate diff check. Same category as the existing **/*.min.js/**/dist/* ignores. Also restores the comment in the three vendored files, stripped by this exact autofix before it landed on this branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #10392 — PR 3 of the hidden-window → QuickJS rollout plan.
Summary
chai@4.5.0through the existing M3 npm-vendoring pipeline (sandbox-vendored-libs-list.ts→chai.generated.ts) and binds its.expectasinsomnia.expect, sopm.test()assertion messages match the hidden-window path byte-for-byte (verified against the real vendored bundle inside an actual QuickJS context — e.g."expected 199 to deeply equal 200") instead of a hand-rolled reimplementation.insomnia.test()/insomnia.test.skip()run entirely inside the VM, buildingrequestTestResultsin the same{testCase, status, executionTime, errorMessage, category}shaperun-script.tsproduces. Apm.test()the script doesn'tawaitis still waited on before the run ends (mirrorswaitForAllTestsDone()).BridgeCallsregistry that drains outstanding calls after the task settles (bounded by the script deadline) — landing feat(quickjs): insomnia.sendRequest() bridge for the QuickJS script sandbox #10392's deferred item so a fire-and-forgetinsomnia.sendRequest(url, callback)actually gets its callback called instead of being silently dropped, with anything still open at the deadline cancelled and rejected with a real, observable error.Test plan
npx tsc --noEmitcleannpx eslintclean on changed filesnpx vitest run src/scripting/— 227/227 passing (run frompackages/insomnia, not the repo root)