From 22a858212c8bb39312c33eba3f2326df008fc479 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Mon, 1 Apr 2024 10:24:21 -0700 Subject: [PATCH] check cdp config from the real config file --- src/testcafe-runner.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/testcafe-runner.ts b/src/testcafe-runner.ts index e9c70609..d23afdaa 100644 --- a/src/testcafe-runner.ts +++ b/src/testcafe-runner.ts @@ -263,8 +263,8 @@ export function buildCommandLine( // If the 'disableNativeAutomation' setting is enabled in the configuration, // it indicates that the CDP connection is disabled, and TestCafe uses its own // proxy to communicate with the browser. -function isCDPDisabled() { - const cfg = require(path.join(__dirname, 'sauce-testcafe-config.cjs')); +function isCDPDisabled(projectPath: string) { + const cfg = require(path.join(projectPath, 'sauce-testcafe-config.cjs')); console.log('cfg: ', cfg); return cfg.disableNativeAutomation; } @@ -347,20 +347,6 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { suiteName, ); - // TestCafe used a reverse proxy for browser automation before. - // With TestCafe 3.0.0 and later, native automation mode was enabled by default, - // see https://testcafe.io/documentation/404237/guides/intermediate-guides/native-automation-mode, - // introducing CDP support for Chrome and Edge. - // This means that HTTP requests can't be routed through the reverse proxy anymore. - // Now, we need to set up an OS-level proxy connection. - if ( - isChromiumBased(suite.browserName) && - !isCDPDisabled() && - isProxyAvailable() - ) { - setupProxy(); - } - if (!(await preExec.run({ preExec: suite.preExec }, preExecTimeout))) { return false; } @@ -376,6 +362,20 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { configFile, ); + // TestCafe used a reverse proxy for browser automation before. + // With TestCafe 3.0.0 and later, native automation mode was enabled by default, + // see https://testcafe.io/documentation/404237/guides/intermediate-guides/native-automation-mode, + // introducing CDP support for Chrome and Edge. + // This means that HTTP requests can't be routed through the reverse proxy anymore. + // Now, we need to set up an OS-level proxy connection. + if ( + isChromiumBased(suite.browserName) && + !isCDPDisabled(projectPath) && + isProxyAvailable() + ) { + setupProxy(); + } + // saucectl suite.timeout is in nanoseconds, convert to seconds const timeout = (suite.timeout || 0) / 1_000_000_000 || 30 * 60; // 30min default