rsnext/test
Antoine Apollis 83b04c8983
Feat/14701 full reload notification (#28866)
## Feature

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

<details>

<summary>Screenshot</summary>

<img width="1388" alt="Screen Shot 2021-12-17 at 2 07 04 PM" src="https://user-images.githubusercontent.com/22380829/146602057-9675455d-cf10-435a-b121-bc462a87fbf3.png">


</details>

Closes: https://github.com/vercel/next.js/issues/14701


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2021-12-17 21:24:13 +00:00
..
.stats-app Remove extra config for PR stats (#30478) 2021-10-27 14:30:39 -05:00
development Include message body in redirect responses (#31886) 2021-12-16 05:41:43 +00:00
e2e Include message body in redirect responses (#31886) 2021-12-16 05:41:43 +00:00
integration Feat/14701 full reload notification (#28866) 2021-12-17 21:24:13 +00:00
lib Fix copying swc binary for isolated tests locally (#32026) 2021-12-02 13:40:38 +01:00
production Update to filter loader specific files from traces (#32267) 2021-12-14 10:41:10 -06:00
unit fixes to allow lazy compilation for import() (#32441) 2021-12-14 11:33:04 +01:00
.gitignore Universal Webpack (#3578) 2018-01-30 16:44:44 +01:00
jest-setup-after-env.ts Update test set-up to leverage playwright when able to (#28634) 2021-09-13 14:36:25 +02:00
readme.md Update test set-up to leverage playwright when able to (#28634) 2021-09-13 14:36:25 +02:00
test-file.txt Add additional file serving tests (#12479) 2020-05-04 11:58:19 -05:00

Writing tests for Next.js

Test types in Next.js

  • e2e: These tests will run against next dev and next start
  • development: These tests only run against next dev
  • production: These tests will run against next start.
  • integration: These tests run misc checks and modes and is where tests used to be added before we added more specific folders. We should not add any more tests here.
  • unit: These are very fast tests that should run without a browser or running next and should be testing a specific utility.

For the e2e, production, and development tests the createNext utility should be used and an example is available here. This creates an isolated Next.js install to ensure nothing in the monorepo is relied on accidentally causing incorrect tests.

All new tests should be written in TypeScript either .ts (or .tsx for unit tests). This will help ensure we catch smaller issues in tests that could cause flakey or incorrect tests.

Best practices

  • When checking for a condition that might take time, ensure it is waited for either using the browser waitForElement or using the check util in next-test-utils.
  • When applying a fix, ensure the test fails without the fix. This makes sure the test will properly catch regressions.