48 Commits

Author SHA1 Message Date
Niklas Mischkulnig 1a7e6bda0f chore: Remove stale build warning (#95813)
Added in https://github.com/vercel/next.js/pull/88001
But it doesn't actually work. It thinks the build is always stale
2026-07-15 18:40:46 +00:00
Sebastian "Sebbie" Silbermann d54719ae4c [test] Fix jest-haste-map warnings (#82995)
Co-authored-by: Hendrik Liebau <mail@hendrik-liebau.de>
2026-02-26 09:57:07 +00:00
JJ Kasper ce738b9f8c Disable jest cache for CI instead of wiping (#90097)
This is aiming to fix sporadic failures from jest transforms which is
most likely caused by the change to output to custom jest-cache folder
and wipe that between runs. Instead this disables the cache via
`--no-cache` flag and also fixes WASM bindings issue that started due to
cache not being available.

x-ref:
https://github.com/vercel/next.js/actions/runs/22109996356/job/63903450669?pr=90096#step:35:493
x-ref:
https://github.com/vercel/next.js/actions/runs/22109996356/job/63903820197?pr=90096#step:35:18167
2026-02-17 10:34:54 -08:00
Niklas Mischkulnig e5043d0e4d [ci] Clear Jest transform cache (#89247)
<!-- 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

### 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 #

-->
2026-01-29 17:25:08 +01:00
Jimmy Lai f3ccca39c7 chore: warn when running tests against stale build (#88001)
i got bit by this often :p 

<!-- 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

### 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 #

-->
2026-01-05 13:26:58 +01:00
JJ Kasper 840643f207 Add experimental routing package for resolving adapter routes (#86404)
This adds a shared routing package which can be used to resolve routes
provided from the adapter API to the final output that should be
served/invoked. It aims to handle all the routing done in `next-server`
and allows a simplified interface for invoking the middleware output
however that is deployed.

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
2025-12-27 20:38:22 -06:00
Sebastian "Sebbie" Silbermann e8185694db [test] Fix test-dev with --projects (#85167) 2025-10-21 15:19:53 +02:00
Sebastian "Sebbie" Silbermann ef888e8eae Typecheck require() calls (#80056) 2025-06-05 22:22:57 +02:00
Tobias Koppers d55bdd711f Turbopack: use correct env var for uploading test results (#77988)
### What?

Use the correct env var

Regression from #77894
2025-04-09 13:28:46 -07:00
Will Binns-Smith 82026906a6 Read and write rspack test manifests by name (#75445)
Previously, rspack test runs were writing to `test-junit-report`, but
were expected to be found at `turbopack-test-junit-report`.

This renames both sides to be `rspack-test-junit-report`.
2025-01-30 14:09:05 +01:00
Sebastian "Sebbie" Silbermann 764f885140 Name default Jest project according to used env variables (#74084) 2024-12-18 19:31:42 +01:00
Sebastian "Sebbie" Silbermann e72dc52be5 Create Jest project for Turbopack (#73769) 2024-12-17 17:25:28 +01:00
Sebastian "Sebbie" Silbermann 3c1f2d6aa9 Ensure inline snapshots can be updated in tests with using syntax (#73704)
Updates `jest-snapshot` to 30 to get Prettier v3 (v2 does not support `using` syntax) and configures Babel (`jest-snapshot` always uses Babel) to support `using` syntax via `@babel/plugin-proposal-explicit-resource-management`.

Could've gone with updating Jest entirely to Alpha but this seems more risky. Meanwhile, `jest-snapshot@30.0.0-alpha.6` seems to be backwards compatible with Jest 29. Their breaking change was only switching to Prettier v2.

## Test plan

With 
```
diff --git a/test/development/acceptance-app/ReactRefreshLogBox.test.ts b/test/development/acceptance-app/ReactRefreshLogBox.test.ts
index e599b54aba..9617c9585b 100644
--- a/test/development/acceptance-app/ReactRefreshLogBox.test.ts
+++ b/test/development/acceptance-app/ReactRefreshLogBox.test.ts
@@ -1200,7 +1200,7 @@ export default function Home() {
       `)
     } else {
       expect(source).toMatchInlineSnapshot(`
-        "app/utils.ts (1:7) @ eval
+        "app/utils.ts (1:8) @ eval
 
         > 1 | throw new Error('utils error')
             |       ^
```

```
$ pnpm 
test-dev test/development/acceptance-app/ReactRefreshLogBox.test.ts -t "should collapse bundler internal stack frames"
● ReactRefreshLogBox app default › should collapse bundler internal stack frames

    expect(received).toMatchInlineSnapshot(snapshot)

    Snapshot name: `ReactRefreshLogBox app default should collapse bundler internal stack frames 1`

    - Snapshot  - 1
    + Received  + 1

    - app/utils.ts (1:8) @ eval
    + app/utils.ts (1:7) @ eval

      > 1 | throw new Error('utils error')
          |       ^
        2 | export function foo(){}
        3 |           

      1200 |       `)
      1201 |     } else {
    > 1202 |       expect(source).toMatchInlineSnapshot(`
           |                      ^
      1203 |         "app/utils.ts (1:8) @ eval
      1204 |
      1205 |         > 1 | throw new Error('utils error')

      at Object.toMatchInlineSnapshot (development/acceptance-app/ReactRefreshLogBox.test.ts:1202:22)

 › 1 snapshot failed
``` 

and `pnpm 
test-dev test/development/acceptance-app/ReactRefreshLogBox.test.ts -t "should collapse bundler internal stack frames" -u` correctly updates (with some whitespace changes but that's a pretty common issue)
2024-12-10 02:41:17 +01:00
Jude Gao 05c101b9d8 Retire replay-io (#73282)
We had this wired up a long time ago but disabled it since it wasn't
helping much. So cleaning it up now.
2024-12-02 17:49:15 -05:00
Sebastian "Sebbie" Silbermann c3475da068 Run @next/codemod tests in CI (#70248)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-09-19 13:28:38 +00:00
Hendrik Liebau d7c0895b06 Re-add support for inline snapshots using prettier v2 (#67530)
With prettier v3 we can not create/update inline snapshopts anymore.

The applied workaround is documented at
https://jestjs.io/docs/configuration/#prettierpath-string.

x-ref:
https://github.com/vercel/next.js/actions/runs/9815872011/job/27105422658
2024-07-07 10:31:22 +02:00
Leah 1e34f80c91 test: use replay jest runner to add current test name to recording (#60438)
### What?

Adds the name of the test that's running when the browser is started to
the recording.

Also makes `RECORD_REPLAY=1` work without `run-tests.js`

Closes PACK-2206
2024-01-10 10:31:32 +01:00
Leah 8bdda745fb chore(CI): improve datadog reporting (#58267) 2023-11-23 15:18:03 +01:00
Balázs Orbán 1b0113bfea chore: remove redundant jest config (#57151)
### What?

Drop redundant Jest config

### Why?

This slipped in by accident. It's already the default value. See https://jestjs.io/docs/configuration#snapshotformat-object
2023-11-01 20:18:57 +00:00
Balázs Orbán 2277797dc2 chore: drop form-data (#57141)
### What?

Dropping `form-data` polyfill as Node.js 18+ versions all expose it on `globalThis`

### Why?

Reduce the amount of shipped code in Next.js

### How?

Similar to #56899

See: https://nodejs.org/docs/latest-v18.x/api/globals.html#class-formdata
2023-10-20 19:25:42 +00: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
Tobias Koppers 15980a66d4 remove --turbo, use --experimental-turbo as --turbo (#55063)
### What?

Switch the default for `--turbo` to the new `--experimental-turbo`, remove the old code in next.js

### Why?

The new approach will be used in future


Closes WEB-1506
2023-09-06 17:46:54 +00:00
Damien Simonin Feugas 39a66d5a08 chore: restore options to opt-in for server-side transpilation (#55010)
### 🧐 What's in there?

As discussed with @huozhi, it's restoring code from #52393 which I forgot to restore in #54891.
It is unlikely to make a difference, but we'll set globalWindow based on the desired test environment. This will not make any difference for most people.

### 🧪 How to test?

Once you've rebuilt your local version of Next, `pnpm testheadless jest/rsc` 

Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2023-09-05 12:55:10 +00:00
Damien Simonin Feugas 3338dd0b31 fix(next-swc): skips client/server only checks when running with Jest to unblock testing (#54891)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-09-04 13:53:41 +02:00
OJ Kwon 2e67454ae5 test(ci): refine test suite name unique (#54013)
### What

Pairing PR to https://github.com/vercel/turbo/pull/5714, which I believe last piece to reenable correct datadog test reports for daily next.js integration + turbopack.

1. Creates a unique suite name to avoid collision / merging across different env / grouped test run
2. revert suitename template (which is for _suites_, not _suite_ for top level) as 1 resolves uniqueness
2023-08-14 19:58:56 +00:00
OJ Kwon e127c51327 test(turbo): allow to run test with --experimental-turbo (#53396)
### What?

Allows to configure test runs with --experimental turbo.
2023-08-09 05:48:54 +00:00
Tobias Koppers 36a7aff6d6 use env var to switch next.js to turbopack mode (#51353)
### What?

this forces all tests to use turbopack independent of the way they invoke next dev

### Why?

some tests were not running turbopack

fixes WEB-1187
2023-06-21 13:52:14 +00:00
OJ Kwon bcb63f3250 ci(workflow): enable test trace upload (#51107)
### What?

WEB-1150. 

This PR is an attempt to upload next.js's test results into datadog test trace to track its status. 

Originally it tried to use automatic trace injection (dd-trace/ci/init). However, due to some of custom environments / setup we use it was not compatible out of the box. Instead, this PR injects a new test reportert to generate junit report, then upload it at once at the end of the testing pipeline.

The reporter is configured to run when necessary variables set, local run should not be affected. 

One thing to note is this report will not count retry results, as it'll create duplicated test entry with multiple results since we runts jest per individual test. This'll allow to detect flaky test easier, but also it means we'll get bit of skewed test results compare to the real world as first failure will be accounted as test fail immediately.
2023-06-12 17:14:13 +00:00
JJ Kasper e4b230677c Add ignores to fix jest-haste failures (#50875)
This pops up occasionally depending on order tests are run and `.next` being present and `jest` trying to process modules inside this folder. 

x-ref: https://github.com/vercel/next.js/actions/runs/5193671295/jobs/9364540542?pr=50869
2023-06-06 22:37:05 +00:00
Hannes Bornö 7bf5dcbbbf Refactor and add more tests to next/font/local (#46627)
Refactor the logic of picking the font file to use for the font fallback
generation. Add additional tests that checks that the correct font file
is picked. Also adds more comments explaining the logic and assumptions
behind the functions.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2023-03-01 15:31:45 -08:00
Tim Neutkens a4a5f84b00 Allow unit tests to be written in packages/next/src (#45222)
Allows `.test.ts` to be colocated next to files so that unit tests can be written in the Next.js core codebase.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2023-01-24 14:32:09 +00:00
Hannes Bornö 539769dddc Mock @next/font when using next/jest (#42413)
Mock `@next/font` when using `next/jest`.

fixes #42379

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-11-03 11:12:46 -07:00
Ethan Arrowood e0cc9cd44f feat(experimental): option to polyfill fetch using undici in Node.js <18 (#40318)
This PR adds a new `experimental.enableUndici` option to let the
developer switch from `next-fetch` to `undici` as the underlying
polyfill for `fetch` in Node.js.

In the current implementation, Next.js makes sure that `fetch` is always
available by using `node-fetch`. However, we do not polyfill in Node.js
18+, since those versions come with their own `fetch` implementation
already, built-in.

Node.js 18+ uses `undici` under the hood, so letting the developer use
`undici` earlier could make the migration easier later on.

Eventually, we hope to be able to stop polyfilling `fetch` in an
upcoming major version of Next.js, shipping less code.


## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Sukka <isukkaw@gmail.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Steven <steven@ceriously.com>
2022-09-27 13:37:28 -07:00
David Ramos 36a6e436b3 Don't swallow test failures caused by POSIX signals (#32688)
* Don't swallow test failures caused by POSIX signals

* Update tests to not import() inside jest

* Update tests

* apply suggestion

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-12-21 12:52:07 -06:00
Tim Neutkens 0196b03621 Experimental next/jest config helper (#31246)
* Experimental next/jest config helper

Co-Authored-By: Maia Teegarden <dev@padmaia.rocks>

* Ensure useTypescript is provided

* Move experimental warning to next/jest

* Remove unused code

* Remove unused imports

Co-authored-by: Maia Teegarden <dev@padmaia.rocks>
2021-11-10 16:16:15 -08:00
Maia Teegarden bc88831619 Add next-swc jest transform (#30993)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-11-08 17:35:04 +01:00
Tim Neutkens 7e370134fb Use import() to load next.config.js (#29935)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Steven <steven@ceriously.com>
2021-10-16 14:22:42 +02: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
JJ Kasper ece79a4e00 Update test config to leverage swc (#28400)
This updates our `jest` configuration to no longer use `babel-jest` and instead uses `@swc/jest` which is much faster. This also updates to the latest version of `jest`, fixes our `tsconfig.json` used for tests (previously types in `node_modules` weren't resolved correctly), and ensures `next/dist` isn't un-necessarily transpiled in `jest`. 

Timings for `yarn testheadless test/unit/` on CI
- before: 3m 30s - 4m ([example run](https://github.com/vercel/next.js/runs/3394701995))
- after: under 1m ([example run](https://github.com/vercel/next.js/pull/28400/checks?check_run_id=3395161621))

Timings for `yarn testheadless test/unit/` locally on m1 mac 
- before: 90.16 seconds
- after: 29.92 seconds
2021-08-23 18:36:56 +00:00
Shu Ding 1bf4cf3e76 Upgrade jest-worker (#23077)
This PR upgrades `jest-worker` and `jest-cli` to the latest pre-release version, also removed `jest-circus` which is included in Jest by default. `jest-worker@next` includes a fix for memory leak that we need (https://github.com/facebook/jest/pull/11187). 

Fixes #22925. This will also improve the OOM issue for `next dev` #15855.
2021-03-16 21:08:35 +00:00
Jan Potoms 32057c849d Use the jest-circus test runner (#12974) 2020-05-16 16:56:06 -04:00
JJ Kasper 8390a474fe Update to output jest data for posting failed tests comment (#10814)
* Update to output jest data for posting failed tests comment

* Add failing test

* Reset retries

* Revert change for testing
2020-03-04 09:54:49 +01:00
Joe Haddad 18a9c7e371 Improve linting rules to catch more errors (#9374)
* Update `packages/`

* Update examples

* Update tests

* Update bench

* Update top level files

* Fix build

* trigger
2019-11-10 19:24:53 -08:00
JJ Kasper 5f40306575 Remove coveralls (#7689) 2019-06-28 09:09:27 -04:00
JJ Kasper 533018f7d0 Update tests for BrowserStack (#6810)
Update tests to setup webdriver stuff in `jest-environment` and re-use one browser session instead of spawning one for each webdriver call to prevent creating too many BrowserStack sessions.
2019-03-29 16:05:53 +01:00
Vagisha Nidhi d43d305092 Test reports are not being published to Azure Pipelines (#5715)
This PR is related to the issue #5713 
The PR helps to publish test results for reporting in Azure Pipelines.

Azure Pipelines provides excellent reporting capabilities that can be leveraged by this PR.
An example report is shown in the image below.
![image](https://user-images.githubusercontent.com/13175100/48767951-e8a73580-ecdd-11e8-8e6a-20d7767d7c1b.png)
2018-11-22 10:12:12 +01:00
Henrik Wenz 95a6a872b6 Refactor test setup (#5391)
- [x] Move jest config from npm scripts to `jest.config.js`
- [x] Remove obsolete cross-env package (we don't need it anymore 🎉)
- [x] Fix bug where tests are not waiting for webdriver to be ready.
2018-10-12 15:32:17 +02:00