fwouts / viteshot

Viteshot 📸 is a fast and simple component screenshot tool based on Vite.
https://viteshot.com
MIT License
214 stars 12 forks source link

NextJs 'next/image' support #73

Open marcoNonvanilla opened 2 years ago

marcoNonvanilla commented 2 years ago

Viteshot does not fully support NextJs. Things like next image currently don't work.

marcoNonvanilla commented 2 years ago

https://github.com/vercel/next.js/blob/canary/examples/with-playwright/playwright.config.ts

ardaerzin commented 2 years ago

our testable components which use next/image are configured this way:

import * as NextImage from 'next/image';
const OriginalNextImage = NextImage.default;

if (process.env.TEST_ENV === 'vreg') {
  Object.defineProperty(NextImage, 'default', {
    configurable: true,
    value: (props) => (
      <OriginalNextImage {...props} unoptimized loader={({ src }) => src} />
    ),
  });
}