From 6044c8cabc4f8451189211e3ea7d2c7a21be1a0f Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Thu, 2 Oct 2025 13:30:00 +0200 Subject: [PATCH 1/4] test: pin @types/react(-dom) for specific vercel/next.js test when running next@latest tests --- .github/workflows/test-e2e.yml | 1 + tests/netlify-deploy.ts | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index dd9d6d164e..62e9edfaa2 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -218,6 +218,7 @@ jobs: # one job may wait for deploys in other jobs (only one deploy may be in progress for # a given alias at a time), resulting in cascading timeouts. DEPLOY_ALIAS: vercel-next-e2e-${{ matrix.version_spec.selector }}-${{ matrix.group }} + NEXT_RESOLVED_VERSION: ${{ matrix.version_spec.version }} run: node run-tests.js -g ${{ matrix.group }}/${{ needs.setup.outputs.total }} -c ${TEST_CONCURRENCY} --type e2e working-directory: ${{ env.next-path }} diff --git a/tests/netlify-deploy.ts b/tests/netlify-deploy.ts index 61ad84e836..97ecd4669c 100644 --- a/tests/netlify-deploy.ts +++ b/tests/netlify-deploy.ts @@ -4,6 +4,7 @@ import fs from 'fs-extra' import { Span } from 'next/src/trace' import { tmpdir } from 'node:os' import path from 'path' +import { satisfies as satisfiesVersionRange } from 'semver' import { NextInstance } from './base' async function packNextRuntimeImpl() { @@ -58,6 +59,23 @@ export class NextDeployInstance extends NextInstance { const setupStartTime = Date.now() + if ( + typeof this.files === 'string' && + this.files.includes('back-forward-cache') && + process.env.NEXT_RESOLVED_VERSION && + satisfiesVersionRange(process.env.NEXT_RESOLVED_VERSION, '<=15.5.4') + ) { + require('console').log('Pinning @types/react(-dom) for back-forward-cache test fixture') + // back-forward-cache test fixture is failing types checking because: + // - @types/react(-dom) types are not pinned + // - fixture uses react `unstable_Activity` export which since fixture was introduced is no longer unstable + // and types were updated for that and no longer provide types for that export (instead provide for `Activity`) + // this adds the pinning of types to version of types that still had `unstable_Activity` type + this.dependencies ??= {} + this.dependencies['@types/react'] = '19.1.1' + this.dependencies['@types/react-dom'] = '19.1.2' + } + // create the test site await super.createTestDir({ parentSpan, skipInstall: true }) From 026a5c67eb6c4b4d3f6a622468a0765c5eaafc34 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Thu, 2 Oct 2025 10:18:44 +0200 Subject: [PATCH 2/4] test: adjust next.js repo test setup to follow deps installation more closely --- tests/netlify-deploy.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/netlify-deploy.ts b/tests/netlify-deploy.ts index 97ecd4669c..92e48bc237 100644 --- a/tests/netlify-deploy.ts +++ b/tests/netlify-deploy.ts @@ -59,6 +59,14 @@ export class NextDeployInstance extends NextInstance { const setupStartTime = Date.now() + const { runtimePackageName, runtimePackageTarballPath } = await packNextRuntime() + + this.dependencies = { + ...(this.dependencies || {}), + // add the runtime package as a dependency + [runtimePackageName]: `file:${runtimePackageTarballPath}`, + } + if ( typeof this.files === 'string' && this.files.includes('back-forward-cache') && @@ -71,7 +79,6 @@ export class NextDeployInstance extends NextInstance { // - fixture uses react `unstable_Activity` export which since fixture was introduced is no longer unstable // and types were updated for that and no longer provide types for that export (instead provide for `Activity`) // this adds the pinning of types to version of types that still had `unstable_Activity` type - this.dependencies ??= {} this.dependencies['@types/react'] = '19.1.1' this.dependencies['@types/react-dom'] = '19.1.2' } @@ -88,10 +95,13 @@ export class NextDeployInstance extends NextInstance { await fs.rename(nodeModules, nodeModulesBak) } - const { runtimePackageName, runtimePackageTarballPath } = await packNextRuntime() - // install dependencies - await execa('npm', ['i', runtimePackageTarballPath, '--legacy-peer-deps'], { + // --force is used to match behavior of `pnpm install --strict-peer-dependencies=false` used by Vercel + // there is a test fixture that have `@babel/preset-flow` as a dependency which has a peer dependency of `@babel/core@^7.0.0-0`, + // but `@babel/core` is not specified as dependency, so we need to automatically attempt to install peer dependencies + // but also not fail in case of peer dependency versions not matching for other fixtures, so `--legacy-peer-deps` is not good option here + // https://github.com/vercel/next.js/blob/7453d200579512a6574f9c53edd716e5cc01615c/test/e2e/babel/index.test.js#L7-L9 + await execa('npm', ['install', '--force'], { cwd: this.testDir, stdio: 'inherit', }) From 7924f03932f0ea703ff11305c42e75833848722f Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Thu, 2 Oct 2025 20:18:31 +0200 Subject: [PATCH 3/4] test: don't ignore buildArgs --- tests/netlify-deploy.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/netlify-deploy.ts b/tests/netlify-deploy.ts index 92e48bc237..0536a81d70 100644 --- a/tests/netlify-deploy.ts +++ b/tests/netlify-deploy.ts @@ -83,6 +83,10 @@ export class NextDeployInstance extends NextInstance { this.dependencies['@types/react-dom'] = '19.1.2' } + if (!this.buildCommand && this.buildArgs && this.buildArgs.length > 0) { + this.buildCommand = `next build ${this.buildArgs.join(' ')}` + } + // create the test site await super.createTestDir({ parentSpan, skipInstall: true }) From ebe626ff134e29cf36d112bf4ad248da31d34ab5 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Wed, 8 Oct 2025 11:26:19 +0200 Subject: [PATCH 4/4] test: set IS_WEBPACK_TEST and IS_TURBOPACK_TEST --- .github/workflows/test-e2e.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 62e9edfaa2..7a955daf4f 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -124,6 +124,24 @@ jobs: echo "version=$NODE_VERSION" >> $GITHUB_OUTPUT echo "Node version for 'next@${{ matrix.version_spec.selector }}' is '$NODE_VERSION'" + - name: Decide default bundler + id: decide-default-bundler + shell: bash + run: | + # we run tests with default bundler for given Next.js version + # some tests have webpack/turbopack specific assertions or skips + # so we need to set IS_WEBPACK_TEST, IS_TURBOPACK_TEST env vars accordingly + # to ensure tests assert behavior of the default bundler + DEFAULT_BUNDLER="webpack" + if [ "${{ matrix.version_spec.selector }}" = "canary" ]; then + # this is not ideal, because we set turbopack default just when explicitly using canary tag as target + # but next@canary are still on 15 major, so we can't yet use major version of resolved next version + # as condition + DEFAULT_BUNDLER="turbopack" + fi + echo "default_bundler=$DEFAULT_BUNDLER" >> $GITHUB_OUTPUT + echo "Default bundler for 'next@${{ matrix.version_spec.selector }}' is '$DEFAULT_BUNDLER'" + - name: setup node uses: actions/setup-node@v5 with: @@ -219,6 +237,8 @@ jobs: # a given alias at a time), resulting in cascading timeouts. DEPLOY_ALIAS: vercel-next-e2e-${{ matrix.version_spec.selector }}-${{ matrix.group }} NEXT_RESOLVED_VERSION: ${{ matrix.version_spec.version }} + IS_WEBPACK_TEST: ${{ steps.decide-default-bundler.outputs.default_bundler == 'webpack' && '1' || '' }} + IS_TURBOPACK_TEST: ${{ steps.decide-default-bundler.outputs.default_bundler == 'turbopack' && '1' || '' }} run: node run-tests.js -g ${{ matrix.group }}/${{ needs.setup.outputs.total }} -c ${TEST_CONCURRENCY} --type e2e working-directory: ${{ env.next-path }} @@ -227,7 +247,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: test-result-${{matrix.version_spec.selector}}-${{ matrix.group }} - path: ${{ env.next-path }}/test/test-junit-report/*.xml + path: ${{ env.next-path }}/test/${{steps.decide-default-bundler.outputs.default_bundler == 'turbopack' && 'turbopack-test-junit-report' || 'test-junit-report'}}/*.xml publish-test-results: name: 'E2E Test Summary (${{matrix.version_spec.selector}})' needs: