npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ek-test-utils

v1.2.2

Published

Zero-config React testing utilities.

Readme

ek-test-utils

Zero-config, frictionless React testing utilities. Focuses on developer experience by eliminating boilerplate and providing essential mocks out of the box.

Downloads npm version License: MIT

ek-test-utils solves the "configuration fatigue" in React testing. It wraps standard testing libraries and provides ready-to-use mocks for Next.js and browser APIs, letting you focus on writing tests instead of setting them up.


Features

  • Zero Config: Pre-configured render and renderHook with automatic provider wrapping.
  • Next.js Ready: Built-in App Router mocks (useRouter, usePathname, etc.) to prevent Next.js specific testing errors.
  • Browser Mocks: Instantly mock window.matchMedia and IntersectionObserver for Jest and Vitest.
  • All-in-One: Re-exports everything from @testing-library/react and @testing-library/user-event.
  • Type Safe: Full TypeScript support.

Installation

npm install -D ek-test-utils
# or
yarn add -D ek-test-utils
# or
pnpm add -D ek-test-utils

Usage

1. The Basics (Drop-in Replacement)

Instead of importing from multiple testing libraries, import everything directly from ek-test-utils. Our custom render automatically wraps your components with necessary providers.

import { render, screen, userEvent } from 'ek-test-utils';
import { MyButton } from './MyButton';

test('renders and clicks button', async () => {
  render(<MyButton />);
  
  const button = screen.getByRole('button', { name: /click me/i });
  await userEvent.click(button);
  
  expect(screen.getByText(/clicked/i)).toBeInTheDocument();
});

2. Testing Hooks

Easily test your custom React hooks without needing to create dummy components.

import { renderHook } from 'ek-test-utils';
import { useCounter } from './useCounter';

test('increments counter', () => {
  const { result } = renderHook(() => useCounter());
  
  // result.current.count
});

3. Next.js App Router Mock

Testing Next.js 13+ components often fails due to missing router contexts. Use our built-in mock to bypass this.

import { mockNextNavigation } from 'ek-test-utils';

// If using Vitest:
vi.mock('next/navigation', () => mockNextNavigation());

// If using Jest:
jest.mock('next/navigation', () => mockNextNavigation());

4. Browser API Mocks

Prevent window.matchMedia and IntersectionObserver errors when testing responsive components or scroll animations. You can add these to your global setup file (e.g., setupTests.ts) or inside individual test files.

import { setupMatchMediaMock, setupIntersectionObserverMock } from 'ek-test-utils';

// Run before your tests
beforeAll(() => {
  setupMatchMediaMock();
  setupIntersectionObserverMock();
});

📄 License

MIT ©


Contributing

Contributions, issues and feature requests are welcome!


Show your support

Give a ⭐️ if this project helped you!