rsnext/test
Eric Matthys f225179378
fix(Link): Do not ignore onMouseEnter prop with absolute href (#32012)
Fixes #22733

Regardless of whether it's recommended that Link be used with external href values or not, they can be used and `onMouseEnter` being swallowed with an external href value is unexpected behavior.

## Bug

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

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2021-12-01 18:32:27 +00:00
..
.stats-app Remove extra config for PR stats (#30478) 2021-10-27 14:30:39 -05:00
development simplify output messages (#31454) 2021-11-16 15:57:30 +00:00
e2e Fix non-concurrent function _document (#31628) 2021-11-19 19:41:19 +00:00
integration fix(Link): Do not ignore onMouseEnter prop with absolute href (#32012) 2021-12-01 18:32:27 +00:00
lib Include submodules in exported type definition (#28316) 2021-11-26 14:46:56 +01:00
production Remove .only and ensure jest lint rules apply for all tests (#31456) 2021-11-15 12:46:12 -06:00
unit Include submodules in exported type definition (#28316) 2021-11-26 14:46:56 +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.