fix: add repl instrumentation for context sharing#1254
Conversation
| throw new Error("Unable to enter REPL before test: browser is not available in the test scope"); | ||
| } | ||
|
|
||
| await __testplaneReplBrowser.switchToRepl({ |
There was a problem hiding this comment.
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", () => { |
There was a problem hiding this comment.
temporal dead zone in js
commit: |
There was a problem hiding this comment.
💡 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"); |
There was a problem hiding this comment.
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 👍 / 👎.
8499c7f to
804688a
Compare
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:
await browser.switchToRepl({ evalInContext: () => {} })function