🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

universal-test-renderer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

universal-test-renderer

A lightweight, JavaScript-only replacement for the deprecated React Test Renderer.

0.6.0
latest
75

Supply Chain Security

100

Vulnerability

83

Quality

89

Maintenance

100

License

Version published
Weekly downloads
537
35.95%
Maintainers
0
Weekly downloads
 
Created

Universal Test Renderer for React

A lightweight, JavaScript-only replacement for the deprecated React Test Renderer.

Why Use It?

  • Pure JavaScript Testing - Test React components in Jest or Vitest without browser or native dependencies
  • Universal - Can be used to simulate React Native or any other React renderer
  • React 19 Ready - Modern alternative as React Test Renderer is now deprecated
  • Lightweight - Minimal dependencies and small bundle size
  • Type-safe - Written in TypeScript with full type definitions
  • Flexible Configuration - Customizable reconciler options for different use cases

Installation

npm install -D universal-test-renderer

Basic Usage

import { act } from "react";
import { createRoot } from "universal-test-renderer";

test("example", () => {
  const renderer = createRoot();
  act(() => {
    renderer.render(<div>Hello!</div>);
  });

  expect(renderer.root?.toJSON()).toMatchInlineSnapshot(`
    <div>
      Hello!
    </div>
  `);
});

Key Differences from React Test Renderer

  • Works at host component level only (no composite components)
  • More flexible reconciler configuration options
  • Uses act from the React package directly

FAQs

Package last updated on 10 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts