Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

@rstest/browser-react

Latest version: v1.0.0-beta.1

Overview

Last scanned
27 Nov 2026
Published
27 Nov 2026
npm package Publisher: 9aoy, chenjiahan, fi3ework
515 Stars
43 Forks
14 Versions
303.8K Downloads
TypeScript Repo language

Scan summary

@rstest/browser-react was last scanned on 27 Nov 2026 at version 1.0.0-beta.1. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 14 versions; the latest was published on 27 Nov 2026.
  • Findings: No rules fired in version 1.0.0-beta.1.
  • Downloads: 303,804 downloads.

Versions

14 versions published
Versions and the rules that fired in each
VersionPublishedStatus
1.0.0-beta.1 LATEST 27 Nov 2026 No rules fired
1.0.0-beta.0 20 Nov 2026 No rules fired
0.12.6 3 Nov 2026 No rules fired
0.12.5 27 Oct 2026 Not shown
0.12.4 19 Oct 2026 Not shown

No rules fired in 1.0.0-beta.1

Findings

Findings for v1.0.0-beta.1. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 1.0.0-beta.1; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

@rstest/browser-react

React component testing utilities for Rstest browser mode (experimental).

This package provides render and renderHook functions for testing React components in a real browser environment. Tests run in an actual browser rather than a simulated DOM like jsdom.

For a complete working example, see the browser example in the Rstest repository.

Installation

npm install @rstest/browser-react
# or
pnpm add @rstest/browser-react

For DOM queries and user interactions, also install:

npm install @testing-library/dom @testing-library/user-event
# or
pnpm install @testing-library/dom @testing-library/user-event

Usage

Basic component testing

Use the render function to mount a React component into the DOM. This is the foundation for all component tests:

import { render } from '@rstest/browser-react';
import { getByRole, getByText } from '@testing-library/dom';
import { expect, test } from '@rstest/core';

test('renders button with text', async () => {
  const { container } = await render(<button>Click me</button>);

  expect(getByRole(container, 'button')).toBeTruthy();
  expect(getByText(container, 'Click me')).toBeTruthy();
});
Testing with providers

When your component depends on React Context (e.g., theme, auth, store), use the wrapper option to wrap it with the necessary providers:

import { render } from '@rstest/browser-react';

const Wrapper = ({ children }: { children: React.ReactNode }) => (
  <ThemeProvider theme="dark">{children}</ThemeProvider>
);

test('renders with theme context', async () => {
  const { container } = await render(<MyComponent />, { wrapper: Wrapper });
  // ...assertions
});
User interactions

Simulate realistic user interactions (clicks, typing, etc.) using @testing-library/user-event:

import { render } from '@rstest/browser-react';
import { getByRole, getByText } from '@testing-library/dom';
import userEvent from '@testing-library/user-event';
import { expect, test } from '@rstest/core';

test('increments counter on click', async () => {
  const { container } = await render(<Counter />);
  const button = getByRole(container, 'button');

  await userEvent.click(button);

  expect(getByText(container, 'Count: 1')).toBeTruthy();
});
Testing hooks

Use renderHook to test custom hooks in isolation, without needing to create a wrapper component. The returned act function ensures state updates are properly flushed:

import { renderHook } from '@rstest/browser-react';
import { useState } from 'react';
import { expect, test } from '@rstest/core';

test('useState updates value', async () => {
  const { result, act } = await renderHook(() => useState(0));

  expect(result.current[0]).toBe(0);

  await act(() => {
    result.current[1](1);
  });

  expect(result.current[0]).toBe(1);
});
Testing hooks with props

When your hook depends on props, use initialProps and rerender to test how the hook responds to prop changes:

import { renderHook } from '@rstest/browser-react';
import { useMemo } from 'react';
import { expect, test } from '@rstest/core';

test('hook reacts to prop changes', async () => {
  const { result, rerender } = await renderHook(
    (props) => useMemo(() => (props?.value ?? 0) * 2, [props?.value]),
    { initialProps: { value: 5 } },
  );

  expect(result.current).toBe(10);

  await rerender({ value: 10 });

  expect(result.current).toBe(20);
});
React strict mode

To enable React Strict Mode for catching potential issues, use the configure function:

import { configure } from '@rstest/browser-react';

configure({ reactStrictMode: true });
Pure entry

The /pure entry (@rstest/browser-react/pure) exports the same API but without automatic cleanup registration. Use it when you need manual control over cleanup timing:

import { cleanup, render } from '@rstest/browser-react/pure';
import { afterEach } from '@rstest/core';

afterEach(async () => {
  await cleanup();
});

API reference

Exports

The default entry (@rstest/browser-react) exports:

  • render - Render a React element into the DOM
  • renderHook - Render a custom hook for testing
  • cleanup - Unmount all rendered components
  • act - Wrap state updates for proper batching
  • configure - Configure render behavior (e.g., React Strict Mode)

Type exports:

  • RenderOptions - Options for render()
  • RenderResult - Return type of render()
  • RenderHookOptions - Options for renderHook()
  • RenderHookResult - Return type of renderHook()
  • RenderConfiguration - Options for configure()

The /pure entry exports the same API but does not register automatic cleanup hooks.

render(ui, options?)

Renders a React element into the DOM.

function render(ui: ReactNode, options?: RenderOptions): Promise<RenderResult>;

type RenderOptions = {
  /** Custom container element to render into */
  container?: HTMLElement;
  /** Base element for queries, defaults to document.body */
  baseElement?: HTMLElement;
  /** Wrapper component (e.g., for providers/context) */
  wrapper?: JSXElementConstructor<{ children: ReactNode }>;
} & (
  | {
      /** Hydrate existing server-rendered HTML instead of creating a new root */
      hydrate: true;
      /** Options passed to React's hydrateRoot */
      createRootOptions?: HydrationOptions;
    }
  | {
      /** @default false */
      hydrate?: false;
      /** Options passed to React's createRoot */
      createRootOptions?: RootOptions;
    }
);

interface RenderResult {
  /** The container element the component is rendered into */
  container: HTMLElement;
  /** The base element for queries, defaults to document.body */
  baseElement: HTMLElement;
  /** Unmount the rendered component */
  unmount: () => Promise<void>;
  /** Re-render the component with new props/element */
  rerender: (ui: ReactNode) => Promise<void>;
  /** Returns the rendered UI as a DocumentFragment (useful for snapshots) */
  asFragment: () => DocumentFragment;
}

For a focused hydration test, the browser test can create matching server markup with renderToString, then pass it through container with hydrate: true. This exercises hydration without starting a Node server, but does not test Node-specific SSR behavior. To test your actual server output, provide that output through container instead. React root options are passed through createRootOptions:

import { renderToString } from 'react-dom/server';

const container = document.createElement('div');
container.innerHTML = renderToString(<App />);

const recoverableErrors: unknown[] = [];
await render(<App />, {
  container,
  hydrate: true,
  createRootOptions: {
    onRecoverableError: (error) => recoverableErrors.push(error),
  },
});
renderHook(callback, options?)

Renders a custom React hook for testing.

function renderHook<Props, Result>(
  callback: (props?: Props) => Result,
  options?: RenderHookOptions<Props>,
): Promise<RenderHookResult<Result, Props>>;

type RenderHookOptions<Props> = RenderOptions & {
  /** Initial props passed to the hook */
  initialProps?: Props;
};

interface RenderHookResult<Result, Props> {
  /** Reference to the latest hook return value */
  result: { current: Result };
  /** Re-render the hook with new props */
  rerender: (props?: Props) => Promise<void>;
  /** Unmount the hook */
  unmount: () => Promise<void>;
  /** Access to act for manual state updates */
  act: (callback: () => unknown) => Promise<void>;
}
act(callback)

Wraps state updates in React's act() for proper batching. Automatically manages the IS_REACT_ACT_ENVIRONMENT global.

function act(callback: () => unknown): Promise<void>;
cleanup()

Unmounts all rendered components and removes their containers from the DOM.

Called automatically before each test when using the default entry. This timing allows you to inspect the DOM after a test failure.

function cleanup(): Promise<void>;
configure(options)

Configure render behavior.

function configure(options: Partial<RenderConfiguration>): void;

interface RenderConfiguration {
  /** Enable React StrictMode wrapper (default: false) */
  reactStrictMode: boolean;
}

Compatibility

  • React >= 18 (React 17 is not supported)
  • Rstest browser mode (experimental)
  • Node.js >= 20.19.0

License

MIT

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm @rstest/browser-react

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Microsoft's Official agent framework Hijacked
AI & VibeSec

BREAKING: Hijacked Releases of Microsoft’s Official agent-framework Steals Azure and CI Credentials

Cry2Wolf: How to Tell a Real Bug from a Nothingburger
AI & VibeSec

Cry2Wolf: Not Every Branded Bug Deserves a Fire Drill

Copy of Template Design OX Blog (3)
Research

Ruby2Shell: Ruby Memory Corruption Flaws Expose Applications to Remote Code Execution, But is it an Actual Risk?

Frame 2085668439 (1)
Group 1261154229