facebook/react · error · Error

No instances found ${message}

Error message

No instances found ${message}

What it means

ReactTestRenderer's singular query helpers (root.find, root.findByType, root.findByProps) go through expectOne, which throws 'No instances found ...' when the predicate matches zero rendered instances. The suffix of the message describes the query (type/props) that produced no match.

Source

Thrown at packages/react-test-renderer/src/ReactTestRenderer.js:456

  });

  return results;
}

function expectOne(
  all: Array<ReactTestInstance>,
  message: string,
): ReactTestInstance {
  if (all.length === 1) {
    return all[0];
  }

  const prefix =
    all.length === 0
      ? 'No instances found '
      : `Expected 1 but found ${all.length} instances `;

  throw new Error(prefix + message);
}

function propsMatch(props: Object, filter: Object): boolean {
  for (const key in filter) {
    if (props[key] !== filter[key]) {
      return false;
    }
  }
  return true;
}

function create(
  element: React$Element<any>,
  options: TestRendererOptions,
): {
  _Scheduler: typeof Scheduler,
  root: void,
  toJSON(): Array<ReactTestRendererNode> | ReactTestRendererNode | null,

View on GitHub (pinned to eafeac097b)

Solutions

  1. Use findAllByType/findAllByProps and assert on the array length for clearer failures
  2. Wrap the state change that renders the component in act() (or await it) so the tree is up to date before querying
  3. Verify the component is actually rendered (check root.findAll output or the rendered JSON) and fix the condition/identity issue (same module instance, no duplicate React)

Example fix

// before
const button = renderer.root.findByType(Button); // throws: No instances found

// after
await act(async () => { rerenderWithConditionTrue(); });
const [button] = renderer.root.findAllByType(Button);
expect(button).toBeDefined();
Defensive patterns

Strategy: validation

Validate before calling

// Check for matches before using the singular query
const matches = root.findAllByType(Button);
if (matches.length === 0) {
  // inspect root.toJSON() to see what actually rendered
  throw new Error('Button not rendered. Tree: ' + JSON.stringify(renderer.toJSON(), null, 2));
}
const button = matches[0];

Prevention

When it happens

Trigger: Calling testRenderer.root.findByType(Component), findByProps({foo: 'bar'}), or find(pred) when no currently rendered instance satisfies the query — e.g. the component is conditionally not rendered, or the query runs before an async state update has rendered.

Common situations: Component hidden behind a loading/feature condition during the query; querying inside an element that only appears after an effect or timer without awaiting act(); component identity mismatch caused by mocking (jest.mock) or duplicate React/module copies so the type never compares equal.

Related errors


AI-assisted analysis of facebook/react@eafeac097b (2026-08-21). Data as JSON: /api/errors/46d9404318a616e2. Report an issue: GitHub.