|
1 | 1 | 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 | +}; |
2 | 13 |
|
3 | 14 | // Build SauceLabs launchers if credentials are available |
4 | 15 | 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', |
6 | 17 | port: 443, |
7 | 18 | path: '/wd/hub', |
8 | 19 | protocol: 'https', |
@@ -44,6 +55,7 @@ const createSauceLabsLaunchers = async () => { |
44 | 55 | browserName: 'firefox', |
45 | 56 | browserVersion: 'latest', |
46 | 57 | platformName: 'Windows 10', |
| 58 | + 'moz:debuggerAddress': true, // Required for SauceLabs Firefox |
47 | 59 | 'sauce:options': sauceOptions, |
48 | 60 | }, |
49 | 61 | }), |
@@ -85,6 +97,23 @@ export default { |
85 | 97 | // Parallel browser execution |
86 | 98 | concurrency: sauceLabsConfig ? 4 : 1, |
87 | 99 |
|
| 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 | + |
88 | 117 | // Custom HTML that sets up QUnit and bridges to WTR |
89 | 118 | // Note: first param is testFrameworkImport (mocha path by default), which we ignore |
90 | 119 | // We use getConfig() to get the actual test file path |
|
0 commit comments