fix(mcp): resolve init-page/init-script paths relative to config file#39322
Open
gpxl-dev wants to merge 2 commits intomicrosoft:mainfrom
Open
fix(mcp): resolve init-page/init-script paths relative to config file#39322gpxl-dev wants to merge 2 commits intomicrosoft:mainfrom
gpxl-dev wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Author
|
@microsoft-github-policy-service agree |
| return configFromCLIOptions(options); | ||
| } | ||
|
|
||
| export async function loadConfig(configFile: string | undefined): Promise<Config> { |
Member
There was a problem hiding this comment.
Can I ask for a stylistic change? Rename this to innerLoadConfig and leave it as is, introduce exported loadConfig below that calls innerLoadConfig and fixes paths below. That way you don't need to call it from 3 different places.
Author
There was a problem hiding this comment.
pushed a commit that I think covers this
yury-s
approved these changes
Feb 26, 2026
Member
yury-s
left a comment
There was a problem hiding this comment.
A couple nits, otherwise looks good, thanks!
|
|
||
| function resolveConfigFileRelativePaths(config: Config, configFile: string): Config { | ||
| const configDir = path.dirname(configFile); | ||
| const resolveFilePath = (filePath: string) => path.isAbsolute(filePath) ? filePath : path.resolve(configDir, filePath); |
Member
There was a problem hiding this comment.
Suggested change
| const resolveFilePath = (filePath: string) => path.isAbsolute(filePath) ? filePath : path.resolve(configDir, filePath); | |
| const resolveFilePath = (filePath: string) => path.resolve(configDir, filePath); |
nit: path.resolve is a noop if filePath is already absolute
| if (!configFile) | ||
| return {}; | ||
|
|
||
| async function innerLoadConfig(configFile: string): Promise<Config> { |
Member
There was a problem hiding this comment.
Suggested change
| async function innerLoadConfig(configFile: string): Promise<Config> { | |
| function innerLoadConfig(configFile: string): Promise<Config> { |
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
browser.initPageandbrowser.initScriptpaths relative to the config file location when loading MCP/CLI config.initPageandinitScriptpaths work.Why
I was using Playwright CLI with a coding agent and wanted to keep
.playwright/cli.config.jsonportable. Relative init paths currently fail unless converted to absolute paths, which makes shared configs harder to use across machines.Testing
npx playwright test --config=tests/mcp/playwright.config.ts --project=chrome tests/mcp/cli-config.spec.ts tests/mcp/init-page.spec.ts