Skip to content

Commit

Permalink
Use --no-sandbox puppeteer only in GH actions
Browse files Browse the repository at this point in the history
  • Loading branch information
tasoskakour committed Jan 12, 2025
1 parent 0a8a4d7 commit 3977f76
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions e2e/login-authorization-code-flow-with-queryfn.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import puppeteer, { Browser } from 'puppeteer';
import { getTextContent } from './test-utils';
import { getTextContent, IS_RUNNING_IN_GITHUB_ACTIONS } from './test-utils';

const URL = 'http://localhost:3000';

Expand All @@ -11,7 +11,9 @@ afterAll((done) => {
});

test('Login with authorization code flow and exchangeCodeForQueryFn works as expected', async () => {
browser = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] });
browser = await puppeteer.launch(
IS_RUNNING_IN_GITHUB_ACTIONS ? { args: ['--no-sandbox', '--disable-setuid-sandbox'] } : {}
);
const page = await browser.newPage();

await page.goto(URL);
Expand Down
6 changes: 4 additions & 2 deletions e2e/login-authorization-code-flow.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import puppeteer, { Browser } from 'puppeteer';
import { getTextContent } from './test-utils';
import { getTextContent, IS_RUNNING_IN_GITHUB_ACTIONS } from './test-utils';

const URL = 'http://localhost:3000';

Expand All @@ -11,7 +11,9 @@ afterAll((done) => {
});

test('Login with authorization code flow works as expected', async () => {
browser = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] });
browser = await puppeteer.launch(
IS_RUNNING_IN_GITHUB_ACTIONS ? { args: ['--no-sandbox', '--disable-setuid-sandbox'] } : {}
);
const page = await browser.newPage();

await page.goto(URL);
Expand Down
8 changes: 4 additions & 4 deletions e2e/login-implicit-grant-flow.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import puppeteer, { Browser } from 'puppeteer';
import { getTextContent } from './test-utils';
import { getTextContent, IS_RUNNING_IN_GITHUB_ACTIONS } from './test-utils';

const URL = 'http://localhost:3000';

Expand All @@ -11,9 +11,9 @@ afterAll((done) => {
});

test('Login with implicit grant flow works as expected', async () => {
browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
});
browser = await puppeteer.launch(
IS_RUNNING_IN_GITHUB_ACTIONS ? { args: ['--no-sandbox', '--disable-setuid-sandbox'] } : {}
);
const page = await browser.newPage();

await page.goto(URL);
Expand Down
2 changes: 2 additions & 0 deletions e2e/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ import { Page } from 'puppeteer';

export const getTextContent = (page: Page, selector: string) =>
page.$eval(selector, (element) => element.textContent);

export const IS_RUNNING_IN_GITHUB_ACTIONS = process.env.GITHUB_ACTIONS === 'true';

0 comments on commit 3977f76

Please sign in to comment.