Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

318
Views
¿Cómo probar un `Documento` personalizado en Next.js?

Tengo un Document personalizado que se copia del documento :

 import Document, { Html, Head, Main, NextScript } from 'next/document' class MyDocument extends Document { static async getInitialProps(ctx) { const initialProps = await Document.getInitialProps(ctx) return { ...initialProps } } render() { return ( <Html lang="en"> <Head /> <body> <Main /> <NextScript /> </body> </Html> ) } } export default MyDocument

Traté de escribir una prueba para ello con lo siguiente a continuación:

 import { render } from '@testing-library/react'; import MyDocument from '../_document.page'; describe('<MyDocument />', () => { it('should render without errors', async () => { const documentProps = {} as any; render(<MyDocument {...documentProps} />); }); });

Pero me sale un error:

 TypeError: Cannot destructure property 'inAmpMode' of '(0 , _react).useContext(...)' as it is null. 6 | const documentProps = {} as any; 7 | > 8 | render(<MyDocument {...documentProps} />); | ^ 9 | }); 10 | });

¿Cuál es la forma recomendada de probar el documento personalizado o cómo resuelvo esto? Gracias.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!