fix(playwright): adapter to support Page and FrameLocator#4
Merged
Conversation
- Fix PwLocatable to accept Playwright Page (split into PwPage and PwLocatable interfaces since Page lacks action methods like click/fill) - Fix selectOption return type to match Playwright's Promise<string[]> - Fix tsconfig rootDir to include e2e and tests directories - Cast .get() results to Playwright Locator in spec for proper matchers https://claude.ai/code/session_01NLDZ5mExRobdxnCYZse77Z
✅ Deploy Preview for ui-testing-library ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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
This PR refactors the Playwright adapter to properly support both Playwright
PageandFrameLocatorobjects, improving type safety and fixing issues with theselectOptionmethod's return type.Key Changes
PwPageinterface to represent the minimal surface needed from a Playwright Page or FrameLocator, distinct fromPwLocatablewhich represents individual locatorsplaywright()to acceptPwPage | PwLocatableinstead of justPwLocatable, allowing it to work with both page-level and locator-level objectsselectOptionreturn type: Updated the return type fromPromise<void>toPromise<string[]>to match Playwright's actual APIlocatablegetter: Added a private getter that safely caststhis.pwtoPwLocatablefor methods that require locator-specific operationslocatablegetter to ensure type safetyselectOptionimplementation: Made it properly async and discards the return value as expected by the adapter interface.get()results toPwLocatorfor Playwright'sexpect()assertionsrootDirfrom"./src"to"."in example-react to include e2e tests in compilationImplementation Details
The refactoring maintains backward compatibility while improving the adapter's flexibility. The separation of
PwPageandPwLocatableinterfaces allows the adapter to handle both entry points (page/frame) and nested locators without type confusion. Thelocatablegetter provides a clean way to access locator-specific methods while keeping the public API flexible.https://claude.ai/code/session_01NLDZ5mExRobdxnCYZse77Z