- Upgrade Vitest 2 to Vitest 5: Breaking Changes in the Order You Hit Them· 8 min read
Upgrade Vitest 2 to Vitest 5: fix ERESOLVE, removed config options, vi.mock inside describe, clearMocks, unawaited resolves, and the changes that fail silently.
- Mock IntersectionObserver in Jest Setup· 5 min read
Fix "IntersectionObserver is not defined" in Jest with a global mock in jest.setup.ts, then trigger isIntersecting to test lazy loading and infinite scroll.
- Fix Jest "window.matchMedia is not a function"· 3 min read
jsdom has no window.matchMedia, so Jest throws a TypeError. Add a plain-function mock to your setup file that survives resetMocks and can match specific queries.
- Fix "ReferenceError: ResizeObserver is not defined" in Jest· 4 min read
Fix "ReferenceError: ResizeObserver is not defined" in Jest or Vitest with a setup-file mock, plus a version that fires the callback so you can test resized layouts.
- Testing Next.js Image Component· 3 min read
Test the Next.js Image component in Jest by mocking next/image as a plain img tag, then assert alt text and src. Includes a component test and common mistakes.
- Testing the next-i18next Library with Jest· 2 min read
Test components that use next-i18next in Jest by mocking useTranslation so t() returns the key. Includes a component test and a global Jest setup file.
- How to Resolve 'Cannot use import statement outside a module' Error when Mocking Swiper JS with Jest· 2 min read
Fix Jest's 'Cannot use import statement outside a module' error with Swiper by letting transformIgnorePatterns transform it, or mock Swiper in unit tests.
- Resolving Jest Error with EMFILE Too Many Open Files· 2 min read
Fix the Jest EMFILE too many open files error by lowering maxWorkers, ignoring build folders, raising ulimit, and running in band on CI.