Skip to content

Commit

Permalink
fix: stop runner from hanging indefinitely within ubuntu docker images [
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfcosta committed Jan 11, 2022
1 parent dab86c8 commit aafdb49
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 16 additions & 0 deletions __tests__/core/gatherer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { wsEndpoint } from '../utils/test-config';
import { devices } from 'playwright-chromium';
import { Server } from '../utils/server';
import { megabitsToBytes } from '../../src/helpers';
import { chromium } from 'playwright-chromium';

jest.mock('../../src/plugins/network');

Expand All @@ -42,12 +43,27 @@ describe('Gatherer', () => {
await server.close();
});

afterEach(() => {
jest.restoreAllMocks();
});

it('boot and close browser', async () => {
const driver = await Gatherer.setupDriver({ wsEndpoint });
expect(typeof driver.page.goto).toBe('function');
await Gatherer.stop();
});

it('uses the disable-gpu flag to start browser', async () => {
const chromiumLaunch = jest.spyOn(chromium, 'launch');
await Gatherer.setupDriver({ wsEndpoint });
expect(chromiumLaunch).toHaveBeenCalledWith(
expect.objectContaining({
args: expect.arrayContaining(['--disable-gpu']),
})
);
await Gatherer.stop();
});

it('setup and dispose driver', async () => {
const driver = await Gatherer.setupDriver({ wsEndpoint });
await Gatherer.dispose(driver);
Expand Down
5 changes: 4 additions & 1 deletion src/core/gatherer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export class Gatherer {
log(`Gatherer: connecting to WS endpoint: ${wsEndpoint}`);
Gatherer.browser = await chromium.connect({ wsEndpoint });
} else {
Gatherer.browser = await chromium.launch(playwrightOptions);
Gatherer.browser = await chromium.launch({
...playwrightOptions,
args: ['--disable-gpu', ...(playwrightOptions?.args ?? [])],
});
}
}
const context = await Gatherer.browser.newContext({
Expand Down

0 comments on commit aafdb49

Please sign in to comment.