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

336
Views
Jest testing dynamic import with jest-next-dynamic

I am trying to test dynamic import in nextjs version 10.2.3, i tried using jest-next-dynamic library which avoid throwing error

TypeError: require.resolveWeak

but when i debug the component in jest test case i get below output and cannot get real component that should be loaded

 <ForwardRef(LoadableComponent) .../>

My test case

it('should render Image component from next/Image', () => {
  await preloadAll();
  defaultProps = getDefaultProps(imgSrcFromAssetsLocation);
  const ContainerImage = shallow(<ContainerImage { ...defaultProps } />);
  console.log(ContainerImage.debug());
  expect(ContainerImage.prop('layout')).toEqual('responsive');
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

After some time i figured out we need to wait for dynamic element to load in test case using waitFor or something similar, documentation of "jest-next-dynamic" does not include this, i found this from below github repo github repo with example

about 4 years ago · Juan Pablo Isaza Report
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!