Commit Graph

28 Commits

Author SHA1 Message Date
Jiwon Choi 5d9ab72cef Add next upgrade --ai and security vulnerability coverage (#98562)
> [!TIP]
> Recommended to review commit by commit.

This PR adds `next upgrade --experimental-ai="security"` flag (alias
`--ai`), which is targeted to help users leverage agents to upgrade
their app to the safe major version when their app's Next.js version has
any security advisories.

Once the command is ran from the user, Next.js will detect the installed
agent harness in user's device, currently limited to Codex and Claude,
and will proceed with starting an agent session once approved. If it is
called within an agent session, the work will continue off within that
agent.

`next upgrade --ai` simply does two things:

- prepare the relevant context to temporary dir
- print hand off prompt, guiding to read those context

The context will guide the agent to run relevant codemods and migration
checklist to proceed. This PR is a base core of the workflow, and will
have wrappers of entry point around this. Also, will add "latest" and
"future" as follow up, which will cover the app to be always latest, and
adopt the future defaults like Cache Components.

This PR also sets up the evals infra and adds evals.
2026-09-18 00:52:20 +02:00
Sebastian "Sebbie" Silbermann 73e89d9f6c Replace deprecated moduleResolution: "node" (#92654) 2026-04-16 20:34:49 +00:00
Sebastian "Sebbie" Silbermann d141874063 Bump TypeScript to 6.0 (#91257) 2026-04-14 12:22:38 +02:00
Andrew Clark 574ac9f0f8 Add @next/playwright package with instant() testing helper (#90470)
Extract the instant navigation testing API into a standalone
@next/playwright package. The instant() helper lets Playwright tests
assert on prefetched/cached UI by deferring dynamic data during
navigations — similar to throttling the network in DevTools.

The package is private: true for now. The goal is to get the scaffolding
ready so we can flip it to public when the API is ready to ship.

The existing inline implementation in the instant navigation test file
is replaced with an import from @next/playwright. The nested scope test
now exercises actual nested instant() calls rather than manipulating the
cookie directly.

The protocol is intentionally minimal (a single cookie) so that other
testing frameworks and dev tools can replicate the behavior with minimal
effort.
2026-02-24 21:27:19 -05:00
Hendrik Liebau 7a2f4ad140 Type-check run-tests.js and remove unused related flag (#88433)
The file already had the `@ts-check` directive, so the IDE did show errors in that file. But since it was not included in the root `tsconfig.json`, those errors were not reported during CI runs.

One issue found this way was that the `related` flag was defined but never used. The referenced script was removed in #67644.
2026-01-12 19:46:11 +01:00
Zack Tanner dd5e3ad611 [ci]: move router-act to top level testing utils (#84653)
We're starting to use this pattern in more places, so this moves `router-act` into our top level testing utils.
2025-10-08 17:01:40 -07:00
Jiwon Choi a432e06ded [Breaking] Remove deprecated built-in AMP (#84312)
This PR removes the deprecated built-in AMP support. Will follow up with
cleaning up the examples, docs, and codemods.
2025-09-30 18:54:26 +02:00
Hendrik Liebau d7fa64ea3b Update eslint and restore .eslintrc.cli.json being used for CLI/CI-based linting (#81553)
This will allow us (again) to selectively use type-checked rules
internally, as stipulated in #67689. In a follow-up, we'll likely add
https://typescript-eslint.io/rules/switch-exhaustiveness-check/ as a
first type-checked rule.
2025-07-11 21:17:40 +02:00
JJ Kasper dc84c3f3e4 Ensure scripts are included in root tsconfig (#79600)
Validated in
https://github.com/vercel/next.js/actions/runs/15232503826/job/42842061880?pr=79600

x-ref: https://github.com/vercel/next.js/pull/79599
2025-05-24 19:38:39 -07:00
Benjamin Woodruff 7049b93e38 chore(CI): Split trailing-slashes suite cases into smaller suites, port to more modern e2e framework (#78890)
Same basic idea as https://github.com/vercel/next.js/pull/78787

This test suite has a lot of timeouts with rspack, which causes it to take a long time to run (though not quite long enough that it breaks the job).

In general, large test suites are good to break up, because they benefit from parallelism.

---

In addition to breaking this test suite up, I also ported it to the new framework, as the way it was patching `next.config.js` was causing problems, since the old integration tests are not run in isolated directories.
2025-05-08 08:38:51 -07:00
Hendrik Liebau 84fde91e03 Update cache handler interface (#76687)
With this PR, we're changing the experimental cache handler interface that's used for `"use cache"` cache handlers:

- A new method `refreshTags(): Promise<void>` has been added.
    - Next.js will call this function periodically, but always before starting a new request. When working with a remote tags service, this method should communicate with the tags service to refresh the local tags manifest accordingly.
- A new method `getExpiration(...tags: string[]): Promise<Timestamp>` has been added.
    - Next.js will call this function for each set of soft tags that are relevant at the start of a request. The result is the maximum timestamp of a revalidate event for the tags.
- The `get` method does not accept the soft tags anymore as its second arg: `get(cacheKey: string): Promise<undefined | CacheEntry>`
   - Checking the expiration of a cache entry via soft tags is now handled by Next.js.
- The `receiveExpiredTags` method has been removed.
    - This was used for two things:
        1. Refreshing the tags in the tags manifest. This was replaced by `refreshTags`.
        2. Setting the passed-in tags as expired in the tags manifest. This was used for redirecting server actions. Discarding cache entries based on these tags is now handled by Next.js internally.

To ease migration, the previous cache handler interface is still supported for now.

closes NAR-110
2025-03-18 16:18:47 +01:00
Wyatt Johnson f4c1a406e4 Partial Fallback Prerendering (#68958)
This work introduces the new concept of **Partial Fallback Prerendering
(PFPR)**.

Traditionally, when a dynamic page needed to be routed to that wasn't
pregenerated, it required a render to generate even the first few bytes
of the static page itself. This resulted in slow page loads for pages
not frequently visited and a reduced Time to First Byte (TTFB) score on
Core Web Vitals (CWV).

PFPR takes advantage of the new systems of Partial Prerendering (PPR)
that allows the application to suspend at different points mid-render,
and resume it later. We mark any unknown parameter access as dynamic
access, and suspend the rendering up to the next suspense boundaries at
those points. Under ideal conditions (correctly placed `<Suspense />`
boundaries or `loading.jsx` files) this generates a static shell that
can be served to users as soon as the request hits Next.js, right out of
the static cache. This minimizes the TTFB for all requests, dynamic or
not for those pages that enable PPR. For example, the following page
would create a usable shell:

```jsx
// /app/users/[userID]/page.jsx
import { Suspense } from 'react'

function Profile({ params }) {
  const { userID } = params
  return <div>Hello {userID}!</div>
}

export default function ProfilePage({ params }) {
  return (
    <div>
      <h1>User Profile</h1>
      <Suspense fallback="Loading...">
        <Profile params={params} />
      </Suspense>
    </div>
  )
}
```

Due to the way that suspense works within React components, access of
params within the root page component would cause the whole page to
suspend. Thankfully, that's where the `loading.jsx` comes in handy.
Adding a `loading.jsx` at a segment will automatically wrap the
`page.jsx` with a suspense boundary, setting the contents of the root
`loading.jsx` as the fallback component to use for it. This lets you
maintain your existing style of accessing parameters at the root of the
components while also taking advantage of PFPR.

To enable this feature, you first need to enable both PPR and PFPR:

```js
module.exports = {
  experimental: {
    ppr: true,
    pprFallbacks: true,
  }
}
```

Once PFPR has stabilized with hosting providers, the experimental flag
will go away and it will become the default with the PPR flag.
2024-08-27 22:31:18 -07:00
Hendrik Liebau 5bb3995473 Fix typescript setup for packages/font and turbo/generators (#67687)
- Include test files when type checking `packages/font`, while still excluding them in `build`.
- Include `turbo/generators` files in root `tsconfig.json` so that they are type checked as well.
2024-07-13 20:32:54 +02:00
Jiwon Choi ce9670ff2e Upgrade TypeScript to v5.5.2 (#67113) 2024-07-04 10:03:46 +02:00
Hendrik Liebau 994d8ee2c3 Fix broken BrowserInterface type (#66461) 2024-06-03 12:56:49 +00:00
Jiachi Liu 9d94372952 chore: extends from shared base tsconfig (#59776) 2023-12-19 18:52:22 +01:00
Jiachi Liu 61a7db63b0 types: cover the tests with root tsconfig.json (#59550) 2023-12-13 11:55:02 +01:00
Sebastian Silbermann 79a8d01ae6 Use new JSX transform (#56294)
Co-authored-by: Jimmy Lai <laijimmy0@gmail.com>
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-12-09 00:17:50 +01:00
Balázs Orbán 33db463fe4 chore: upgrade jest (#56909)
### What?

Upgrade jest to its latest version

### Why?

#56899 fails because historically Jest stripped the globals in Node.js, but 28+ isn't doing that anymore. If we upgrade, we don't have to keep track of Node.js globals and when they are added. This will be useful in removing even more polyfills for things that are natively shipped in Node.js now.

### How?

Jest 29 introduced a change to the snapshot format: https://jestjs.io/blog/2022/08/25/jest-29

First, I tried setting the old compat option to not require updating snapshots, but some tests were still failing: https://dev.azure.com/nextjs/next.js/_build/results?buildId=70633&view=logs&j=8af7cf9c-43a1-584d-6f5c-57bad8880974&t=7ae70e63-3625-50f4-6764-5b3e72b4bd7a&l=273 So going through the pain now instead.
2023-10-19 17:38:24 +00:00
Jimmy Lai c2fd08063c perf: replace zod with superstruct (#56083)
This PR replaces the usage of Zod in the App Router in favour of a smaller validation library. We don't use much of zod's more advanced capabilities so it doesn't make sense to import all of it on the server at the moment.

Also added some unit tests.

This results in a 44kb win, which will impact cold boot

Before:
<img width="594" alt="CleanShot 2023-09-27 at 13 34 09@2x" src="https://github.com/vercel/next.js/assets/11064311/43cc7687-947d-40a1-9e1e-c2a60caf53c0">
After:
<img width="564" alt="CleanShot 2023-09-27 at 13 34 48@2x" src="https://github.com/vercel/next.js/assets/11064311/c3d3f5d6-e1f6-4969-bd11-dcd191d34ce6">


<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the PR.
- Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to understand the PR)
- When linking to a Slack thread, you might want to share details of the conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2023-09-28 11:05:36 +02:00
Tim Neutkens ea148f3581 Move client-navigation test to test/development (#55888)
Moves the client-navigation test suite to be isolated as part of
test/development.
Tried to make the minimal amount of changes neccesary to ensure the
tests pass first before using the newer `NextInstance` methods.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2023-09-24 11:38:53 +02:00
Leah 5d54eaaf18 type check tests (and convert next-test-utils.js to ts) (#51071)
Enables type checking for tests in CI and fixes a bunch of things related to that
2023-06-23 17:42:50 +00:00
Leah c1c3675fc4 refactor tests for readability (#51051)
You'll probably want to disable whitespace in the diff

## Description

This allows for better editor support by using `describe` or functions called `describe` with the same syntax instead of custom names.

Changes:
- `nextTestSetup` can be used instead of `createNextDescribe` keeping the same behaviour but being called inside a `describe` "block" (not applied everywhere)
- `getSnapshotTestDescribe` replaced with a custom `describe.each`
- `sandbox` helper function for `acceptance`/`acceptance-app` merged into a single shared one
- `outdent` to remove the indent from inline files in tests which helps with consistent snapshots
2023-06-21 19:47:21 +00:00
Justin Ridgewell 8ae2df0f10 Integrate next-* crates from Turbopack (#47019)
Update workspace cargo deps
Update cargo deps to point to local workspace
Ignore too-many-arguments warnings
Fix clippy errors
Update pnpm workspaces
exclude integration tests from unit tests CI
rust-analyzer settings
add rust flags and env vars
2023-03-13 14:33:17 +01:00
Michael Novotny edd395a7d3 Adds tests to ensure eslint-plugin-next's available rules are properly exported and recommended rules are correctly defined. (#38183)
* Adds tests to ensure `eslint-plugin-next`'s available rules are properly exported and recommended rules are defined correctly.

* Condenses imports.

* Sets default recommended value.

* replace Object.hasOwn for node 14

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-30 11:31:33 -05:00
Hannes Bornö 5739edc7cf Ignore popstate with invalid state (#37110)
* Ignore popstate with invalid state

* Make tests pass

* i18n case fixed

* Fix lint error

* Unhandled Promise Rejection

* Revert "Unhandled Promise Rejection"

This reverts commit ac4fde7654.

* fix type check

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-05-28 20:07:44 -05:00
JJ Kasper a92a5caec2 Update test set-up to leverage playwright when able to (#28634)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-09-13 14:36:25 +02:00
JJ Kasper 005b13f1ac Move unit tests to one folder and migrate them to TypeScript (#28427)
* Move unit tests to one folder

* Migrate unit tests to TypeScript

* add test types to lint

* Ensure ts(x) tests are run with util

* Add tsx extension to jest config

* bump
2021-08-24 07:52:45 -05:00