vue-lynx/testing-library

Vue Lynx Testing Library provides simple utilities for testing Vue 3 Lynx components in a Node.js environment. It renders components through the full dual-thread pipeline (Background Thread renderer → Main Thread native elements → JSDOM) so your tests exercise the same code path as production.

Inspired by Vue Testing Library and @lynx-js/react/testing-library

For setup instructions and examples, see the VueLynx Testing Library guide.

Quick Example

import { expect, it, vi } from 'vitest';
import { h, defineComponent } from 'vue-lynx';
import { render, fireEvent } from 'vue-lynx-testing-library';

it('fires tap event', () => {
  const onClick = vi.fn();
  const Comp = defineComponent({
    setup() {
      return () => h('view', { bindtap: onClick }, [
        h('text', null, 'Click me'),
      ]);
    },
  });

  const { container, getByText } = render(Comp);
  fireEvent.tap(container.querySelector('view')!);

  expect(onClick).toHaveBeenCalledTimes(1);
  expect(getByText('Click me')).not.toBeNull();
});

Auto-cleanup is built in — after each test, the rendered app is automatically unmounted and the JSDOM is reset.

API Reference

NameKind
cleanupFunction
fireEventFunction
getQueriesForElementFunction
renderFunction
waitForUpdateFunction
withinFunction
RenderResultInterface
eventMapVariable
screenVariable