Skip to content

fix: add repl instrumentation for context sharing#1254

Open
shadowusr wants to merge 1 commit into
masterfrom
users/shadowusr/TESTPLANE-995.repl-instrumentation
Open

fix: add repl instrumentation for context sharing#1254
shadowusr wants to merge 1 commit into
masterfrom
users/shadowusr/TESTPLANE-995.repl-instrumentation

Conversation

@shadowusr
Copy link
Copy Markdown
Member

What's done?

Implemented a way to "see" the file context when in REPL mode. Before, REPL console didn't have access to anything that surrounds the test. Now, running commands in REPL is very close to literally running them inside the test.

This works through code instrumentation at test reading time and only when repl is enabled. The idea is this:

  1. Instrument all tests, by literally injecting await browser.switchToRepl({ evalInContext: () => {} }) function
  2. In REPL, use that evalInContext function that we got from the test body to execute code, which naturally is executed inside test body

throw new Error("Unable to enter REPL before test: browser is not available in the test scope");
}

await __testplaneReplBrowser.switchToRepl({
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the core idea, what's added to test body. We use this in switchToRepl command implementation.

assert.match(result, /await browser\.url\("about:blank"\)/);
});

it("should not read browser from TDZ if test callback declares local browser", () => {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporal dead zone in js

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 14, 2026

Open in StackBlitz

npm i https://pkg.pr.new/gemini-testing/testplane@1254

commit: 804688a

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8499c7fa32

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

function mkBabelParser(): RecastParser | null {
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const babelParser: typeof import("@babel/parser") = require("@babel/parser");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Make the parser available in published installs

When --repl-before-test is used from an installed testplane package, this require("@babel/parser") usually fails because @babel/parser is listed only under devDependencies in package.json, not dependencies. The catch then returns null, so instrumentReplBeforeTest silently skips all instrumentation and the new scoped REPL context never works for normal consumers unless their project happens to install a compatible parser itself; move the parser to runtime dependencies or avoid requiring it for this feature.

Useful? React with 👍 / 👎.

@shadowusr shadowusr force-pushed the users/shadowusr/TESTPLANE-995.repl-instrumentation branch from 8499c7f to 804688a Compare May 14, 2026 22:24
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.

1 participant