From 8d0ef2f8ba48f43bb1e10446b98d0a71bc3dbb8c Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Wed, 18 Jan 2023 11:34:07 +0000 Subject: [PATCH 1/5] test(nextjs): Move playwright deps installation into CI pipeline --- .github/workflows/build.yml | 1 + packages/nextjs/package.json | 3 +-- packages/nextjs/playwright.config.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f83624f23cbf..caee576a5ed4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -490,6 +490,7 @@ jobs: NODE_VERSION: ${{ matrix.node }} run: | cd packages/nextjs + yarn playwright install-deps yarn test:integration # Ember tests are separate from the rest because they are the slowest part of the test suite, and making them a diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 04bfe2ffe659..052c4fa69001 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -68,10 +68,9 @@ "test:build": "yarn ts-node test/buildProcess/runTest.ts", "test:unit": "jest", "test:integration": "./test/run-integration-tests.sh && yarn test:types", - "test:integration:ci": "run-s test:integration:clean test:integration:client:ci test:integration:server", "test:integration:prepare": "(cd test/integration && yarn build && yarn start)", "test:integration:clean": "(cd test/integration && rimraf .cache node_modules build)", - "test:integration:client": "yarn playwright install-deps && yarn playwright test test/integration/test/client/", + "test:integration:client": "yarn playwright test test/integration/test/client/", "test:integration:client:ci": "yarn test:integration:client --browser='all' --reporter='line'", "test:integration:server": "export NODE_OPTIONS='--stack-trace-limit=25' && jest --config=test/integration/jest.config.js test/integration/test/server/", "test:types": "cd test/types && yarn test", diff --git a/packages/nextjs/playwright.config.ts b/packages/nextjs/playwright.config.ts index a7c80dc9e39d..af6bddff5da7 100644 --- a/packages/nextjs/playwright.config.ts +++ b/packages/nextjs/playwright.config.ts @@ -1,7 +1,7 @@ import type { PlaywrightTestConfig } from '@playwright/test'; const config: PlaywrightTestConfig = { - retries: 2, + retries: 0, // We do not accept flakes. timeout: 12000, use: { baseURL: 'http://localhost:3000', From d1399cad8f32d2792af69bf1c9707f11b402d80d Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Wed, 18 Jan 2023 11:57:05 +0000 Subject: [PATCH 2/5] clean up --- packages/nextjs/package.json | 2 -- packages/nextjs/playwright.config.ts | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 052c4fa69001..d5a399c99e2d 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -68,10 +68,8 @@ "test:build": "yarn ts-node test/buildProcess/runTest.ts", "test:unit": "jest", "test:integration": "./test/run-integration-tests.sh && yarn test:types", - "test:integration:prepare": "(cd test/integration && yarn build && yarn start)", "test:integration:clean": "(cd test/integration && rimraf .cache node_modules build)", "test:integration:client": "yarn playwright test test/integration/test/client/", - "test:integration:client:ci": "yarn test:integration:client --browser='all' --reporter='line'", "test:integration:server": "export NODE_OPTIONS='--stack-trace-limit=25' && jest --config=test/integration/jest.config.js test/integration/test/server/", "test:types": "cd test/types && yarn test", "test:watch": "jest --watch", diff --git a/packages/nextjs/playwright.config.ts b/packages/nextjs/playwright.config.ts index af6bddff5da7..010812504574 100644 --- a/packages/nextjs/playwright.config.ts +++ b/packages/nextjs/playwright.config.ts @@ -1,4 +1,5 @@ import type { PlaywrightTestConfig } from '@playwright/test'; +import * as path from 'path'; const config: PlaywrightTestConfig = { retries: 0, // We do not accept flakes. @@ -8,7 +9,8 @@ const config: PlaywrightTestConfig = { }, workers: 3, webServer: { - command: 'yarn test:integration:prepare', + cwd: path.join(__dirname, 'test', 'integration'), + command: 'yarn start', port: 3000, }, }; From bcebd8fd5cc8635cfa97d6c64971f87decec1438 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Wed, 18 Jan 2023 12:11:37 +0000 Subject: [PATCH 3/5] Use cache --- .github/workflows/build.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index caee576a5ed4..d75489c1fb7b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -485,12 +485,27 @@ jobs: with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} + - uses: actions/cache@v3 + name: Check if Playwright browser is cached + id: playwright-cache + with: + path: ${{ steps.npm-cache-dir.outputs.dir }} + key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}} + - name: Install Playwright browser if not cached + if: steps.playwright-cache.outputs.cache-hit != 'true' + continue-on-error: true # playwright needs node >= 14 + run: npx playwright install --with-deps + env: + PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}} + - name: Install OS dependencies of Playwright if cache hit + if: steps.playwright-cache.outputs.cache-hit == 'true' + continue-on-error: true # playwright needs node >= 14 + run: npx playwright install-deps - name: Run tests env: NODE_VERSION: ${{ matrix.node }} run: | cd packages/nextjs - yarn playwright install-deps yarn test:integration # Ember tests are separate from the rest because they are the slowest part of the test suite, and making them a From 84b1ddd23dd91494ba50a048e7717a15c3f4f79c Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Wed, 18 Jan 2023 12:17:14 +0000 Subject: [PATCH 4/5] Add missing steps --- .github/workflows/build.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d75489c1fb7b..85dd0b260ff9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -485,6 +485,14 @@ jobs: with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} + - name: Get npm cache directory + id: npm-cache-dir + run: | + echo "::set-output name=dir::$(npm config get cache)" + - name: Get Playwright version + id: playwright-version + run: | + echo "::set-output name=version::$(node -p "require('@playwright/test/package.json').version")" - uses: actions/cache@v3 name: Check if Playwright browser is cached id: playwright-cache From 1eb069e66a71817b9e8e49e91cab57a7cb5bf4ca Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Wed, 18 Jan 2023 12:36:51 +0000 Subject: [PATCH 5/5] Fix flakey `tracingFetch` test --- .../test/client/tracingFetch.test.ts | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/nextjs/test/integration/test/client/tracingFetch.test.ts b/packages/nextjs/test/integration/test/client/tracingFetch.test.ts index b776921ff188..f4b464ac55fa 100644 --- a/packages/nextjs/test/integration/test/client/tracingFetch.test.ts +++ b/packages/nextjs/test/integration/test/client/tracingFetch.test.ts @@ -28,17 +28,21 @@ test('should correctly instrument `fetch` for performance tracing', async ({ pag }); // @ts-ignore - We know that `spans` is inside Transaction envelopes - expect(transaction[0].spans[0]).toMatchObject({ - data: { method: 'GET', url: 'http://example.com', type: 'fetch' }, - description: 'GET http://example.com', - op: 'http.client', - parent_span_id: expect.any(String), - span_id: expect.any(String), - start_timestamp: expect.any(Number), - timestamp: expect.any(Number), - trace_id: expect.any(String), - status: expect.any(String), - }); + expect(transaction[0].spans).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + data: { method: 'GET', url: 'http://example.com', type: 'fetch' }, + description: 'GET http://example.com', + op: 'http.client', + parent_span_id: expect.any(String), + span_id: expect.any(String), + start_timestamp: expect.any(Number), + timestamp: expect.any(Number), + trace_id: expect.any(String), + status: expect.any(String), + }), + ]), + ); expect(await countEnvelopes(page, { url: '/fetch', envelopeType: 'transaction', timeout: 2500 })).toBe(1); });