Next 11.1.2 throws `TypeError: DocumentComponent.renderDocument is not a function`
See original GitHub issue🐛 Bug Report
Using next-page-tester 0.28.0 with next 11.1.2 (and possibly 11.1.1?) throws the following error with useDocument: true:
TypeError: DocumentComponent.renderDocument is not a function
4 | describe("404 page", () => {
5 | it("has a 404 status code", async () => {
> 6 | const { render } = await getPage({ route: "/asdf1234", useDocument: true })
| ^
7 | render()
8 | expectStatusCode(404)
9 | })
at node_modules/next-page-tester/dist/_document/render.js:96:34
at Object.executeAsIfOnServer (node_modules/next-page-tester/dist/server.js:33:16)
at getPage (node_modules/next-page-tester/dist/getPage.js:70:31)
at Object.<anonymous> (__tests__/pages/404.js:6:24)
It looks like it’s reaching this line of code https://github.com/toomuchdesign/next-page-tester/blob/bbde6b3714805c3e2d002f390ea28fa25aa6f61e/src/_document/render.tsx#L151
But the renderDocument function was deleted in this commit 😦
Reproduction
I’m guessing it’s trivial enough to bump your next version and see your tests fail
Expected behavior
No errors 😃
Jest patch
Have you patched Jest as described here?
- yes
- no, because I’m using Jest 27
Run npx envinfo --preset jest
Paste the results here:
System:
OS: macOS 11.4
CPU: (8) arm64 Apple M1
Binaries:
Node: 15.11.0 - ~/.nvm/versions/node/v15.11.0/bin/node
Yarn: 1.22.5 - /opt/homebrew/Cellar/yvm/4.1.1/shim/yarn
npm: 7.6.0 - ~/.nvm/versions/node/v15.11.0/bin/npm
npmPackages:
jest: ^27.0.0 => 27.0.4
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
NExt JS v11.1.2 Build issues - TypeError: c.props.href. ...
In my particular case I'm populating the href for the favicon with a CMS (sanity.io), and the function that generated that resource was ......
Read more >Advanced Features: Custom `Document`
React components outside of <Main /> will not be initialized by the browser. Do not add application logic here or custom CSS (like...
Read more >Server-side rendered styled-components with Nextjs
I've recently worked on setting up Next.js with styled-components, ... ://github.com/zeit/next.js/#user-content-custom-document) component ...
Read more >Getting start with Next.js Framework for server-rendered ...
The aim is to support “shadow CSS” resembling of Web Components, which unfortunately do not support server-rendering and are JS-only.
Read more >ESP_MDF release/v1.0 mqtt_example root node restart ...
Next 11.1.2 throws `TypeError: DocumentComponent.renderDocument is not a function`, 7, 2021-09-22, 2022-10-07.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @thepuzzlemaster, thanks for pinging us. #268 is a GH issues targeting
useDocumentoption re-enabling.I’ve spent a few few hours on the topic: I could get document rendering to work again with still 3 red tests (of which one concerning
headelements update).Since I won’t be able to spend so much time on this, I will try to release a working breaking version with
useDocumentoption disabled (#267).Current document rendering implementation heavily relies on next.js internal files. A different approach might consist of re-implementing the minimum document rendering functionality with as little as possible dependencies toward next.js. If possible 😃
In the meanwhile I’ll be happy to support anybody who wanted to give it a try. PR #264 is a good starting point.