Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
chore: test headless version (#237)
Browse files Browse the repository at this point in the history
* Run tests in headless mode
  • Loading branch information
Lykhoyda authored Jan 11, 2023
1 parent 34852cb commit 18c8232
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install
run: yarn --prefer-offline --frozen-lockfile
- name: Tests
run: 'xvfb-run --auto-servernum --server-args="-screen 0, 1920x1080x24" yarn run test:${{matrix.automation}}:${{ matrix.mm-version }} --timeout 50000'
run: 'yarn run test:${{matrix.automation}}:${{ matrix.mm-version }} --timeout 50000'
- uses: actions/upload-artifact@v3
if: always()
with:
Expand Down
6 changes: 6 additions & 0 deletions src/jest/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import { DapeteerJestConfig } from "./global";
export const DAPPETEER_DEFAULT_CONFIG: DappeteerLaunchOptions = {
metaMaskVersion: RECOMMENDED_METAMASK_VERSION,
browser: "chrome",
playwrightOptions: {
headless: true,
},
puppeteerOptions: {
headless: true,
},
};

export async function getDappeteerConfig(): Promise<DapeteerJestConfig> {
Expand Down
3 changes: 2 additions & 1 deletion src/setup/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ export async function launchPlaywright(
browser = await (
await import("playwright")
).chromium.launchPersistentContext(tmpdir, {
headless: false,
headless: options.playwrightOptions?.headless,
args: [
`--disable-extensions-except=${metamaskPath}`,
`--load-extension=${metamaskPath}`,
...(options.playwrightOptions?.args || []),
`${options.puppeteerOptions?.headless ? "--headless=chrome" : ""}`,
],
...(options.playwrightOptions ?? {}),
});
Expand Down
3 changes: 2 additions & 1 deletion src/setup/puppeteer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ export async function launchPuppeteer(
const pBrowser = await (
await import("puppeteer")
).default.launch({
headless: false,
headless: options.puppeteerOptions?.headless,
args: [
`--disable-extensions-except=${metamaskPath}`,
`--load-extension=${metamaskPath}`,
...(options.puppeteerOptions?.args || []),
`${options.puppeteerOptions?.headless ? "--headless=chrome" : ""}`,
],
...(options.puppeteerOptions ?? {}),
});
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export type DappeteerLaunchOptions = {
//fallbacks to installed dependency and prefers playwright if both are installed
automation?: "puppeteer" | "playwright";
browser: "chrome";
puppeteerOptions?: Omit<Parameters<typeof puppeteerLaunch>[0], "headless">;
playwrightOptions?: Omit<PlaywrightLaunchOptions, "headless">;
puppeteerOptions?: Parameters<typeof puppeteerLaunch>[0];
playwrightOptions?: PlaywrightLaunchOptions;
};

declare global {
Expand Down
6 changes: 6 additions & 0 deletions test/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ export const mochaHooks = {
browser: "chrome",
metaMaskVersion:
process.env.METAMASK_VERSION || dappeteer.RECOMMENDED_METAMASK_VERSION,
playwrightOptions: {
headless: true,
},
puppeteerOptions: {
headless: true,
},
});

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
Expand Down
6 changes: 6 additions & 0 deletions test/global_flask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export const mochaHooks = {
metaMaskVersion:
process.env.METAMASK_VERSION || dappeteer.RECOMMENDED_METAMASK_VERSION,
metaMaskFlask: true,
playwrightOptions: {
headless: true,
},
puppeteerOptions: {
headless: true,
},
});

const snapServers = await buildSnaps();
Expand Down

0 comments on commit 18c8232

Please sign in to comment.