From 4690bb4cc9299c8633272d406824caa9ac9136e9 Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Tue, 21 Jan 2025 22:50:13 +0900 Subject: [PATCH] Disable GPU acceleration in CI tests to mitigate flakiness --- .circleci/config.yml | 1 + .github/workflows/test-win.yml | 1 + test/browser/browsers/chrome.ts | 11 +++++++++++ 3 files changed, 13 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index ab352ea4..ad965b33 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -99,6 +99,7 @@ commands: name: Jest command: npm run test:coverage -- --ci --reporters=default --reporters=jest-junit <<#parameters.runInBand>>-i<><<^parameters.runInBand>>--maxWorkers=2<> environment: + CHROME_DISABLE_GPU: 1 # Disable GPU acceleration to mitigate flaky tests JEST_JUNIT_CLASSNAME: '{filepath}' JEST_JUNIT_OUTPUT_DIR: tmp/test-results MARP_TEST_CI: 1 diff --git a/.github/workflows/test-win.yml b/.github/workflows/test-win.yml index 02ad3a06..61ab1bc4 100644 --- a/.github/workflows/test-win.yml +++ b/.github/workflows/test-win.yml @@ -48,6 +48,7 @@ jobs: # https://stackoverflow.com/a/59365905 - name: Jest env: + CHROME_DISABLE_GPU: 1 # Disable GPU acceleration to mitigate flaky tests JEST_JUNIT_CLASSNAME: '{filepath}' JEST_JUNIT_OUTPUT_DIR: tmp/test-results MARP_TEST_CI: 1 diff --git a/test/browser/browsers/chrome.ts b/test/browser/browsers/chrome.ts index 2b380990..4ae232a9 100644 --- a/test/browser/browsers/chrome.ts +++ b/test/browser/browsers/chrome.ts @@ -132,6 +132,17 @@ describe('ChromeBrowser', () => { }) describe('Disabling GPU', () => { + it('does not add --disable-gpu argument if CHROME_DISABLE_GPU environment variable is not defined', async () => { + delete process.env.CHROME_DISABLE_GPU + await new ChromeBrowser({ path: '/path/to/chrome' }).launch() + + expect(puppeteer.launch).toHaveBeenCalledWith( + expect.objectContaining({ + args: expect.not.arrayContaining(['--disable-gpu']), + }) + ) + }) + it('adds --disable-gpu argument if CHROME_DISABLE_GPU environment variable is defined', async () => { process.env.CHROME_DISABLE_GPU = '1' await new ChromeBrowser({ path: '/path/to/chrome' }).launch()