rsnext/test
Mateusz Burzyński 482fccb922
Adding head element checking for root layout (#43597)
### Update

We removed the `<head>` element checking for root layout in #41621. Since we also need `<head>` for preload in the future, and also css-in-js will require that. We're adding back the `head` element checking to make sure user always provide valid root layout including it.

### Issue

An issue was reported [here](https://github.com/mui/material-ui/issues/34905#issuecomment-1331945868) that the Emotion/MUI site was suffering from FOUC.

After an inspection, I noticed that the SSRed HTML didn't contain the inserted styles at all - despite them being inserted through `useServerInsertedHTML`. I managed to debug it down and discovered that their layout was missing `<head></head>` and thus the stream transformer skipped the insertion altogether cause of this check:
fbc98abab3/packages/next/server/node-web-streams-helper.ts (L177-L183)

I've figured that at the very least we could surface this as a console error in development to nudge the user to fix the missing `<head/>`

cc @huozhi 



Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2022-12-02 16:41:46 +00:00
..
.stats-app Merge app internal chunk into main chunk for layouts (#41902) 2022-10-27 16:50:46 -07:00
__mocks__ Update Edge Runtime (#38862) 2022-07-21 18:29:19 +00:00
development Minimized runtime errors in app dir (#43511) 2022-11-30 20:37:48 -08:00
e2e Adding head element checking for root layout (#43597) 2022-12-02 16:41:46 +00:00
integration Update next/link default legacyBehavior (#42623) 2022-11-30 20:01:29 -08:00
lib Minimized runtime errors in app dir (#43511) 2022-11-30 20:37:48 -08:00
production Fix app render: escape segment value #42626 (#42823) 2022-11-17 17:45:39 -08:00
unit Update next/link default legacyBehavior (#42623) 2022-11-30 20:01:29 -08:00
.gitignore Fix server html insertion target (#42591) 2022-11-07 18:16:13 +01:00
jest-setup-after-env.ts Adds tests to ensure eslint-plugin-next's available rules are properly exported and recommended rules are correctly defined. (#38183) 2022-06-30 11:31:33 -05:00
jest.d.ts Adds tests to ensure eslint-plugin-next's available rules are properly exported and recommended rules are correctly defined. (#38183) 2022-06-30 11:31:33 -05:00
readme.md refactor: split up CONTRIBUTING.md (#40515) 2022-09-16 14:54:58 -07:00
test-file.txt

See Testing for more information on how you can run/write/debug tests for Next.js.