Skip to content

Commit 82ab146

Browse files
authored
fix: merge proxy into project-level contextOptions (#315)
1 parent cc96a84 commit 82ab146

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

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)