For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /api/testing-library/index.md.

@blotch/angular-lynx-testing-library

Renders a component through the Lynx renderer in a unit test. Then you find and tap its elements with Testing Library queries that read Lynx's accessibility attributes. import { render } from '@blotch/angular-lynx-testing-library';

Usage

src/app/counter/counter.ts
import { Component, signal } from '@angular/core';
import { LYNX_ELEMENTS } from '@blotch/angular-lynx';

@Component({
  selector: 'app-counter',
  imports: [LYNX_ELEMENTS],
  template: `
    <view
      [accessibility-element]="true"
      accessibility-traits="button"
      accessibility-label="Add one"
      (bindtap)="increment()"
    >
      <text>Taps: {{ taps() }}</text>
    </view>
  `,
})
export class Counter {
  readonly taps = signal(0);

  increment(): void {
    this.taps.update((n) => n + 1);
  }
}
src/app/counter/counter.test.ts
import {
  fireEvent,
  render,
  waitForUpdate,
} from '@blotch/angular-lynx-testing-library';
import { describe, expect, it } from 'vitest';

import { Counter } from './counter';

describe('Counter', () => {
  it('counts taps', async () => {
    const { getByRole, getByText } = await render(Counter);

    fireEvent.tap(getByRole('button', { name: 'Add one' }));
    await waitForUpdate();

    expect(getByText('Taps: 1')).toBeTruthy();
  });
});

API

PageWhat it covers
render()render(), renderDirective(), cleanup(), waitForUpdate() and their types
Element queriesscreen, within(), queries, *ByRole and *ByAccessibilityLabel
fireEventfireEvent(), its arguments and bubbling, and eventMap
Event referenceEvery fireEvent method, and the template binding it runs
Device fakesHow the fakes work, and which function fakes each service
Device and hostApp state, network, Android's back button
Bluetooth, NFC and Wi-FiBluetooth LE devices, NFC tags, Wi-Fi networks
Sensors and audioLocation, motion, biometrics, audio recorder, audio player
Camera, photos and filesImage picker, barcode scanner, photo library, file picker
Contacts and calendarThe address book, the contact picker, the calendar's event editor
Sharing and linksOpened links, incoming links, shortcuts, shares to the app
Sign-in, reviews and trackingSign in with Apple, store reviews, tracking

Setup entry

The package also has a @blotch/angular-lynx-testing-library/setup entry, which prepares the Lynx test environment. It fakes the phone's native modules, too: see Device fakes.

ng test loads it for you.

Re-exports

ExportFromDescription
ComponentRef@angular/core (type)The type of componentRef