2024-07-08 12:27:29 +00:00
|
|
|
import type { Options, Services } from "@wdio/types";
|
2024-07-11 09:02:34 +00:00
|
|
|
import { BrowserStackCapabilities } from "@wdio/types/build/Capabilities";
|
2024-07-08 12:27:29 +00:00
|
|
|
|
|
|
|
const capabilities: WebdriverIO.Capabilities[] = [];
|
|
|
|
const services: Services.ServiceEntry[] = [];
|
|
|
|
|
|
|
|
const headless = process.argv.includes("--headless");
|
|
|
|
const chrome = process.argv.includes("--chrome");
|
2024-07-08 17:24:41 +00:00
|
|
|
const firefox = process.argv.includes("--firefox");
|
2024-07-08 18:11:24 +00:00
|
|
|
const edge = process.argv.includes("--edge");
|
2024-07-11 09:02:34 +00:00
|
|
|
const browserstack = process.argv.includes("--browserstack");
|
|
|
|
const oldVersions = process.argv.includes("--oldVersions");
|
|
|
|
|
|
|
|
let user: string | undefined = undefined;
|
|
|
|
let key: string | undefined = undefined;
|
|
|
|
let setupLogging = async () => {};
|
|
|
|
let reportLogging = async () => {};
|
2024-07-08 12:27:29 +00:00
|
|
|
|
|
|
|
if (chrome) {
|
|
|
|
const args = ["--disable-gpu"];
|
|
|
|
if (headless) {
|
|
|
|
args.push("--headless");
|
|
|
|
}
|
|
|
|
capabilities.push({
|
|
|
|
"wdio:maxInstances": 1,
|
|
|
|
browserName: "chrome",
|
|
|
|
"goog:chromeOptions": {
|
|
|
|
args,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
services.push("chromedriver");
|
|
|
|
}
|
|
|
|
|
2024-07-08 18:11:24 +00:00
|
|
|
if (edge) {
|
|
|
|
const args = ["--disable-gpu"];
|
|
|
|
if (headless) {
|
|
|
|
args.push("--headless");
|
|
|
|
}
|
|
|
|
capabilities.push({
|
|
|
|
"wdio:maxInstances": 1,
|
|
|
|
browserName: "MicrosoftEdge",
|
|
|
|
"ms:edgeOptions": {
|
|
|
|
args,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
services.push("edgedriver");
|
|
|
|
}
|
|
|
|
|
2024-07-08 17:24:41 +00:00
|
|
|
if (firefox) {
|
|
|
|
const args = [];
|
|
|
|
if (headless) {
|
|
|
|
args.push("-headless");
|
|
|
|
}
|
|
|
|
capabilities.push({
|
|
|
|
"wdio:maxInstances": 1,
|
|
|
|
browserName: "firefox",
|
|
|
|
"moz:firefoxOptions": {
|
|
|
|
args,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
services.push("geckodriver");
|
|
|
|
}
|
|
|
|
|
2024-07-11 09:02:34 +00:00
|
|
|
if (browserstack) {
|
|
|
|
user = process.env["BROWSERSTACK_USERNAME"];
|
|
|
|
key = process.env["BROWSERSTACK_ACCESS_KEY"];
|
|
|
|
if (!user || !key) {
|
|
|
|
throw new Error(
|
|
|
|
"BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY environment variables are required",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
const buildIdentifier =
|
|
|
|
process.env["BROWSERSTACK_BUILD_ID"] || crypto.randomUUID();
|
|
|
|
const buildName = process.env["BROWSERSTACK_BUILD_NAME"] || buildIdentifier;
|
|
|
|
const bsOptions: BrowserStackCapabilities = {
|
|
|
|
buildName,
|
|
|
|
buildIdentifier,
|
|
|
|
projectName: "Ruffle Selfhosted",
|
|
|
|
networkLogs: true,
|
|
|
|
consoleLogs: "info",
|
|
|
|
idleTimeout: 300, // Max time the browser's main thread can be blocked
|
|
|
|
};
|
|
|
|
services.push([
|
|
|
|
"browserstack",
|
|
|
|
{
|
|
|
|
testObservability: true,
|
|
|
|
testObservabilityOptions: {
|
|
|
|
projectName: "Ruffle Selfhosted",
|
|
|
|
buildName,
|
|
|
|
},
|
|
|
|
browserstackLocal: true,
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Relatively latest versions for Mobile
|
|
|
|
|
|
|
|
capabilities.push({
|
|
|
|
browserName: "Chrome",
|
|
|
|
"bstack:options": {
|
|
|
|
deviceName: "Google Pixel 8",
|
|
|
|
osVersion: "14.0",
|
|
|
|
...bsOptions,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
capabilities.push({
|
|
|
|
browserName: "Safari",
|
|
|
|
"bstack:options": {
|
|
|
|
deviceName: "iPhone 15",
|
|
|
|
osVersion: "17",
|
|
|
|
deviceOrientation: "portrait",
|
|
|
|
...bsOptions,
|
|
|
|
},
|
|
|
|
"wdio:exclude": [
|
|
|
|
"./test/integration_tests/keyboard_input/test.ts", // Doesn't work on iOS at time of writing
|
|
|
|
"./test/polyfill/classic_frames_provided/test.ts", // Flaky on iOS
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
// These are our supposed minimum-supported browsers
|
|
|
|
if (oldVersions) {
|
|
|
|
capabilities.push({
|
|
|
|
browserName: "Chrome",
|
|
|
|
"bstack:options": {
|
|
|
|
os: "Windows",
|
|
|
|
osVersion: "10",
|
|
|
|
browserVersion: "87.0",
|
|
|
|
...bsOptions,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
capabilities.push({
|
|
|
|
browserName: "Firefox",
|
|
|
|
"bstack:options": {
|
|
|
|
os: "Windows",
|
|
|
|
osVersion: "10",
|
|
|
|
browserVersion: "84.0",
|
|
|
|
...bsOptions,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
capabilities.push({
|
|
|
|
browserName: "Safari",
|
|
|
|
"bstack:options": {
|
|
|
|
os: "OS X",
|
|
|
|
osVersion: "Big Sur",
|
|
|
|
browserVersion: "14.1",
|
|
|
|
...bsOptions,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
setupLogging = async () => {
|
|
|
|
await browser.execute(() => {
|
|
|
|
if (console.logs === undefined) {
|
|
|
|
const log = console.log.bind(console);
|
|
|
|
console.log = function (...args) {
|
|
|
|
console.logs.push({ level: "info", message: args });
|
|
|
|
log.apply(console, args);
|
|
|
|
};
|
|
|
|
const warn = console.warn.bind(console);
|
|
|
|
console.warn = function (...args) {
|
|
|
|
console.logs.push({ level: "warn", message: args });
|
|
|
|
warn.apply(console, args);
|
|
|
|
};
|
|
|
|
const error = console.error.bind(console);
|
|
|
|
console.error = function (...args) {
|
|
|
|
console.logs.push({ level: "error", message: args });
|
|
|
|
error.apply(console, args);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
console.logs = [];
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
reportLogging = async () => {
|
|
|
|
const logs = await browser.execute(() => {
|
|
|
|
const logs = console.logs;
|
|
|
|
console.logs = [];
|
|
|
|
return logs;
|
|
|
|
});
|
|
|
|
if (logs) {
|
|
|
|
for (const log of logs) {
|
|
|
|
const message = `Console: ${log.message}`;
|
|
|
|
await driver.executeScript(
|
|
|
|
`browserstack_executor: {"action": "annotate", "arguments": {"data":${JSON.stringify(message)},"level": ${JSON.stringify(log.level)}}}`,
|
|
|
|
[],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-07-08 12:27:29 +00:00
|
|
|
services.push([
|
|
|
|
"static-server",
|
|
|
|
{
|
|
|
|
folders: [
|
|
|
|
{ mount: "/dist", path: "./dist" },
|
|
|
|
{ mount: "/test_assets", path: "./test_assets" },
|
|
|
|
{ mount: "/test", path: "./test" },
|
|
|
|
],
|
|
|
|
port: 4567,
|
|
|
|
},
|
|
|
|
]);
|
2024-07-08 10:58:51 +00:00
|
|
|
|
2024-07-11 09:02:34 +00:00
|
|
|
declare global {
|
|
|
|
interface Console {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
logs: { level: string; message: any[] }[];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// @ts-expect-error TS2375 Undefined is the same as not specified here
|
2024-07-08 10:58:51 +00:00
|
|
|
export const config: Options.Testrunner = {
|
2024-07-11 09:02:34 +00:00
|
|
|
user,
|
|
|
|
key,
|
2020-05-23 09:43:22 +00:00
|
|
|
runner: "local",
|
2024-05-27 19:47:55 +00:00
|
|
|
specs: [
|
|
|
|
"./test/polyfill/**/test.ts",
|
|
|
|
"./test/js_api/*.ts",
|
|
|
|
"./test/integration_tests/**/test.ts",
|
|
|
|
],
|
2020-05-23 09:43:22 +00:00
|
|
|
maxInstances: 10,
|
2024-07-08 12:27:29 +00:00
|
|
|
capabilities,
|
2020-05-23 09:43:22 +00:00
|
|
|
logLevel: "info",
|
|
|
|
bail: 0,
|
|
|
|
baseUrl: "http://localhost",
|
2020-06-09 23:11:20 +00:00
|
|
|
waitforTimeout: 30000,
|
2020-05-23 09:43:22 +00:00
|
|
|
connectionRetryTimeout: 120000,
|
|
|
|
connectionRetryCount: 3,
|
2024-07-11 09:02:34 +00:00
|
|
|
specFileRetries: 2,
|
2024-07-08 12:27:29 +00:00
|
|
|
services,
|
2020-05-23 09:43:22 +00:00
|
|
|
framework: "mocha",
|
|
|
|
reporters: ["spec"],
|
|
|
|
mochaOpts: {
|
|
|
|
ui: "bdd",
|
2022-04-25 20:38:16 +00:00
|
|
|
timeout: 120000,
|
2020-05-23 09:43:22 +00:00
|
|
|
},
|
2024-07-11 09:02:34 +00:00
|
|
|
|
|
|
|
async beforeTest() {
|
|
|
|
await setupLogging();
|
|
|
|
},
|
|
|
|
|
|
|
|
async afterTest() {
|
|
|
|
await reportLogging();
|
|
|
|
},
|
2020-05-23 09:43:22 +00:00
|
|
|
};
|