Member Junction
    Preparing search index...

    React Test Harness for testing React components in an isolated browser environment

    This test harness uses a single browser page instance and is NOT safe for parallel test execution on the same instance. For parallel testing, create separate ReactTestHarness instances:

    // ✅ CORRECT - Parallel testing with separate instances
    const results = await Promise.all(tests.map(async (test) => {
    const harness = new ReactTestHarness(options);
    await harness.initialize();
    try {
    return await harness.testComponent(test);
    } finally {
    await harness.close();
    }
    }));
    // ❌ WRONG - Parallel testing on same instance (will cause conflicts)
    const harness = new ReactTestHarness(options);
    await harness.initialize();
    const results = await Promise.all(tests.map(test => harness.testComponent(test)));

    Attaching to an existing browser
    --------------------------------
    Pass `connect` (or set `MJ_REACT_TEST_HARNESS_CONNECT`) to attach to an
    already-running browser instead of launching one`http(s)://` endpoints use
    CDP, `ws(s)://` endpoints use a Playwright server. See {@link TestHarnessOptions}
    (inherited from BrowserContextOptions) for `connect`, `connectType`, and
    `reuseExistingContext`. NOTE: when `reuseExistingContext` is true, separate
    ReactTestHarness instances share one browser context and are therefore NOT
    isolatedkeep the default (fresh context) for parallel runs.
    Index

    Constructors

    Methods

    • Parameters

      • html: string

      Returns {
          toContainText: (text: string) => void;
          toHaveAttribute: (
              selector: string,
              attribute: string,
              value?: string,
          ) => void;
          toHaveElement: (selector: string) => void;
          toHaveElementCount: (tagName: string, count: number) => void;
      }

    • Parameters

      • name: string
      • testFn: () => Promise<void>

      Returns Promise<{ duration: number; error?: string; name: string; passed: boolean }>

    • Parameters

      • tests: { fn: () => Promise<void>; name: string }[]

      Returns Promise<
          {
              duration: number;
              failed: number;
              passed: number;
              results: {
                  duration: number;
                  error?: string;
                  name: string;
                  passed: boolean;
              }[];
              total: number;
          },
      >