Skip to content

Commit 77f6bbf

Browse files
anupam-slclaude
andcommitted
fix: merge proxy into project-level contextOptions
Playwright resolves project config by replacing root-level `use` properties with project-level ones. When a project defines its own `use.contextOptions` (e.g. reducedMotion), it completely overrides the root-level contextOptions — losing the SC tunnel proxy settings and causing scripted requests to fail with ENOTFOUND. This iterates over user-defined projects and merges proxy settings into each project's contextOptions so both coexist. Fixes INT-11 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent eacdf62 commit 77f6bbf

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

src/sauce.config.cjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,26 @@ if ('HTTP_PROXY' in process.env && process.env.HTTP_PROXY !== '') {
8282
proxy,
8383
ignoreHTTPSErrors: true,
8484
};
85+
86+
// Merge proxy settings into each project's contextOptions as well.
87+
// Playwright resolves project config by merging project-level `use` over
88+
// root-level `use`. If a project defines its own `use.contextOptions`
89+
// (e.g. { reducedMotion: 'reduce' }), it completely replaces the
90+
// root-level contextOptions — which would lose the SC tunnel proxy
91+
// settings and cause requests to fail with ENOTFOUND.
92+
// By merging proxy settings directly into each project's contextOptions,
93+
// both the user's project-level options and the proxy coexist.
94+
if (Array.isArray(userConfig.projects)) {
95+
for (const project of userConfig.projects) {
96+
if (project.use?.contextOptions) {
97+
project.use.contextOptions = {
98+
...project.use.contextOptions,
99+
proxy,
100+
ignoreHTTPSErrors: true,
101+
};
102+
}
103+
}
104+
}
85105
}
86106

87107
function arrMerger(objValue, srcValue) {

src/sauce.config.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,26 @@ if ('HTTP_PROXY' in process.env && process.env.HTTP_PROXY !== '') {
8282
proxy,
8383
ignoreHTTPSErrors: true,
8484
};
85+
86+
// Merge proxy settings into each project's contextOptions as well.
87+
// Playwright resolves project config by merging project-level `use` over
88+
// root-level `use`. If a project defines its own `use.contextOptions`
89+
// (e.g. { reducedMotion: 'reduce' }), it completely replaces the
90+
// root-level contextOptions — which would lose the SC tunnel proxy
91+
// settings and cause requests to fail with ENOTFOUND.
92+
// By merging proxy settings directly into each project's contextOptions,
93+
// both the user's project-level options and the proxy coexist.
94+
if (Array.isArray(userConfig.projects)) {
95+
for (const project of userConfig.projects) {
96+
if (project.use?.contextOptions) {
97+
project.use.contextOptions = {
98+
...project.use.contextOptions,
99+
proxy,
100+
ignoreHTTPSErrors: true,
101+
};
102+
}
103+
}
104+
}
85105
}
86106

87107
function arrMerger(objValue, srcValue) {

0 commit comments

Comments
 (0)