Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Load TestCafe config from project folder #224

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
// 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
return cfg.disableNativeAutomation;
}

Expand Down Expand Up @@ -346,20 +346,6 @@
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 @@ -375,6 +361,20 @@
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 Expand Up @@ -402,7 +402,7 @@
}

if (require.main === module) {
const packageInfo = require(path.join(__dirname, '..', 'package.json'));

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

View workflow job for this annotation

GitHub Actions / test

Require statement not part of import statement
console.log(`Sauce TestCafe Runner ${packageInfo.version}`);
console.log(`Running TestCafe ${packageInfo.dependencies?.testcafe || ''}`);
const { nodeBin, runCfgPath, suiteName } = getArgs();
Expand Down
Loading