-
Notifications
You must be signed in to change notification settings - Fork 91
test: next.js repo tests adjustments #3168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6044c8c
026a5c6
7924f03
ebe626f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,34 @@ 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}`, | ||
| } | ||
|
Comment on lines
+64
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this isn't strictly needed change, but I do find it nicer to let next.js repo e2e utils to just produce especially as I used |
||
|
|
||
| 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['@types/react'] = '19.1.1' | ||
| this.dependencies['@types/react-dom'] = '19.1.2' | ||
| } | ||
|
Comment on lines
+70
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is something that would fail on next.js repo as well if they run the test against current I don't love this hack, but this test generally passes and I'd rather not skip it. Creating triaging issue doesn't make much sense either, so only option left is to "patch" the test when we run against current |
||
|
|
||
| if (!this.buildCommand && this.buildArgs && this.buildArgs.length > 0) { | ||
| this.buildCommand = `next build ${this.buildArgs.join(' ')}` | ||
| } | ||
|
Comment on lines
+86
to
+88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to support this test https://github.com/vercel/next.js/blob/a7d3aecafedc920221a885b8ab00f35f6de5e91c/test/e2e/react-compiler/react-compiler.test.ts#L42 , without something like this |
||
|
|
||
| // create the test site | ||
| await super.createTestDir({ parentSpan, skipInstall: true }) | ||
|
|
||
|
|
@@ -70,10 +99,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', | ||
| }) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those env vars are used by next test helpers and will impact
isTurbopacketc checks - for example like one used in this test https://github.com/vercel/next.js/blob/a7d3aecafedc920221a885b8ab00f35f6de5e91c/test/e2e/esm-externals/esm-externals.test.ts