Skip to content

Commit 6bae8e8

Browse files
committed
Continue work on WTR
1. ✅ Fixture routing via middleware 2. ✅ Sauce region configurability via SAUCE_REGION env var 3. ✅ Firefox moz:debuggerAddress: true capability
1 parent 6060dea commit 6bae8e8

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

web-test-runner.config.mjs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
import { playwrightLauncher } from '@web/test-runner-playwright';
2+
import path from 'path';
3+
import fs from 'fs';
4+
5+
// Map SAUCE_REGION env var to hostname
6+
const sauceRegionHostnames = {
7+
'us': 'ondemand.us-west-1.saucelabs.com',
8+
'us-west-1': 'ondemand.us-west-1.saucelabs.com',
9+
'us-east-4': 'ondemand.us-east-4.saucelabs.com',
10+
'eu': 'ondemand.eu-central-1.saucelabs.com',
11+
'eu-central-1': 'ondemand.eu-central-1.saucelabs.com',
12+
};
213

314
// Build SauceLabs launchers if credentials are available
415
const sauceLabsConfig = process.env.SAUCE_ACCESS_KEY ? {
5-
hostname: 'ondemand.us-west-1.saucelabs.com',
16+
hostname: sauceRegionHostnames[process.env.SAUCE_REGION] || 'ondemand.us-west-1.saucelabs.com',
617
port: 443,
718
path: '/wd/hub',
819
protocol: 'https',
@@ -44,6 +55,7 @@ const createSauceLabsLaunchers = async () => {
4455
browserName: 'firefox',
4556
browserVersion: 'latest',
4657
platformName: 'Windows 10',
58+
'moz:debuggerAddress': true, // Required for SauceLabs Firefox
4759
'sauce:options': sauceOptions,
4860
},
4961
}),
@@ -85,6 +97,23 @@ export default {
8597
// Parallel browser execution
8698
concurrency: sauceLabsConfig ? 4 : 1,
8799

100+
// Middleware to serve test fixtures from src/test/test_helpers/fixtures/
101+
middleware: [
102+
function serveFixtures(context, next) {
103+
if (context.url.startsWith('/test_helpers/fixtures/')) {
104+
const filePath = path.join(process.cwd(), 'src/test', context.url);
105+
if (fs.existsSync(filePath)) {
106+
context.body = fs.createReadStream(filePath);
107+
const ext = path.extname(filePath).toLowerCase();
108+
const mimeTypes = { '.png': 'image/png', '.jpg': 'image/jpeg', '.gif': 'image/gif' };
109+
context.type = mimeTypes[ext] || 'application/octet-stream';
110+
return;
111+
}
112+
}
113+
return next();
114+
},
115+
],
116+
88117
// Custom HTML that sets up QUnit and bridges to WTR
89118
// Note: first param is testFrameworkImport (mocha path by default), which we ignore
90119
// We use getConfig() to get the actual test file path

0 commit comments

Comments
 (0)