Skip to content

Commit

Permalink
check cdp config from the real config file
Browse files Browse the repository at this point in the history
  • Loading branch information
tianfeng92 committed Apr 1, 2024
1 parent be40696 commit 22a8582
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/testcafe-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Check warning on line 267 in src/testcafe-runner.ts

View workflow job for this annotation

GitHub Actions / test

Require statement not part of import statement
console.log('cfg: ', cfg);
return cfg.disableNativeAutomation;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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

Expand Down

0 comments on commit 22a8582

Please sign in to comment.