feat(plugins): add expose plugin for direct helper-internals injection#5549
Merged
feat(plugins): add expose plugin for direct helper-internals injection#5549
expose plugin for direct helper-internals injection#5549Conversation
Exposes Playwright/Puppeteer/WebDriver helper properties (page, browser, browserContext, wdio client) as scenario arguments via a live proxy. Reads helper.[property] on every access so mid-test reassignment from switchToNextTab/openNewTab is reflected automatically. Bypasses MetaStep wrapping so calls run as native SDK calls. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Adds a new
exposeplugin that injects helper internals (Playwright/Puppeteerpage,browser,browserContext; WebDriverbrowser/wdio client; or any helper property) as destructurable scenario arguments.Shorthand
inject: { page: 'page' }resolves to the first configured browser helper that exposes the property.Design highlights
Container.helpers(name)?.[property], so mid-test reassignments fromswitchToNextTab,openNewTab,switchToPreviousTab(Playwright_setPagecalls at lines 1864/1890/1948; Puppeteer at 1112/1135/1180) are reflected automatically.MetaStepwrapping. Registers aProxy(function(){}, ...)sotypeof === 'function'triggers the short-circuit inContainer.support()(lib/container.js:171-173) — the proxy is returned as-is and method calls run as native Playwright/Puppeteer SDK calls (no extra step lines, no proxy semantics altering behavior).helper.pageisnullorundefined(dry-run, before_before, after_stopBrowser), the proxy returnsundefinedfor any property access instead of throwing.I,test,suite), unknown shorthand properties, and malformed values.Files
lib/plugin/expose.js— plugin implementation (~150 lines)test/unit/plugin/expose_test.js— 13 unit tests covering live reassignment, null tolerance,this-binding, raw return values, shorthand resolution, and validation pathsdocs/advanced.md— new "Direct Helper Access" sectionTest plan
npx mocha test/unit/plugin/expose_test.js— 13/13 passnpx mocha test/unit/plugin/— full plugin suite green (no regression)./bin/codecept.js dry-run --config test/acceptance/codecept.Playwright.js— clean, all 77 tests load({ I, page })against real Playwright (manual)await page.url()must reflect new tab (manual)🤖 Generated with Claude Code