rsnext/test
JJ Kasper ff474b01db
Update include/exclude handling for output tracing (#30184)
* Use micromatch for excludes and add tests

* update compiled

* check glob array once per file
2021-10-22 13:55:45 -05:00
..
.stats-app Update stats-config for release stats (#29654) 2021-10-05 17:49:24 -05:00
development improve CI stability (#30171) 2021-10-22 12:35:38 +02:00
e2e Avoid TypeError when comparing path param (#29821) 2021-10-13 04:56:38 +00:00
integration Update include/exclude handling for output tracing (#30184) 2021-10-22 13:55:45 -05:00
lib add experimental.urlImports option (#30079) 2021-10-21 13:14:57 +02:00
production Fix missing trace items and migrate required files test (#29649) 2021-10-05 13:52:19 -05:00
unit [ESLint] Add add next/script support for no-unwanted-polyfillio rule (#28944) 2021-10-22 11:19:24 +00:00
.eslintrc.json [ESLint] Remove error when file patterns are unmatched + ESLint setup changes (#27119) 2021-07-16 20:19:08 +02: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.