Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 11 additions & 2 deletions scripts/run-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ interface CliOptions {
mode: E2EMode;
platform: BrowserPlatform;
suite: E2ESuite;
headed: boolean;
passthroughArgs: string[];
}

function parseCliOptions(argv: string[]): CliOptions {
let mode: E2EMode = "production";
let platform: BrowserPlatform = "chrome";
let suite: E2ESuite = "smoke";
let headed = false;
const passthroughArgs: string[] = [];

for (let index = 0; index < argv.length; index += 1) {
Expand Down Expand Up @@ -72,10 +74,14 @@ function parseCliOptions(argv: string[]): CliOptions {
}
throw new Error(`Unsupported suite: ${String(value)}`);
}
if (arg === "--headed") {
headed = true;
continue;
}
passthroughArgs.push(arg);
}

return { mode, platform, suite, passthroughArgs };
return { mode, platform, suite, headed, passthroughArgs };
}

async function runCommand(cmd: string[], extraEnv: Record<string, string> = {}): Promise<void> {
Expand Down Expand Up @@ -120,12 +126,15 @@ async function main(): Promise<void> {
`--outdir=${extensionBuildDir}`,
]);

const sharedE2EEnv = {
const sharedE2EEnv: Record<string, string> = {
E2E_BROWSER: options.platform,
E2E_EXTENSION_PATH: extensionBuildDir,
E2E_SUITE: options.suite,
RUN_E2E: "1",
};
if (options.headed) {
sharedE2EEnv.E2E_HEADED = "1";
}

if (options.mode === "development") {
await runCommand(
Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/e2e-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const EXTENSION_PATH = path.resolve(
process.env.E2E_EXTENSION_PATH || path.join(__dirname, "../../build/"),
);
const IS_CI = process.env.CI === "true" || process.env.CI === "1";
const IS_HEADED = process.env.E2E_HEADED === "true" || process.env.E2E_HEADED === "1";

export type BrowserType = "chrome" | "firefox";
export type E2ESuite = "smoke" | "full";
Expand Down Expand Up @@ -105,7 +106,7 @@ async function launchChrome(): Promise<Browser> {
args.push("--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage");
}
return puppeteer.launch({
headless: IS_CI,
headless: !IS_HEADED,
args,
defaultViewport: null,
});
Expand Down Expand Up @@ -323,7 +324,7 @@ async function resolveFirefoxExtensionHost(browser: Browser, extensionId: string
async function launchFirefox(): Promise<Browser> {
const browser = await puppeteer.launch({
browser: "firefox",
headless: IS_CI,
headless: !IS_HEADED,
defaultViewport: null,
});

Expand Down
Loading