> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# @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

```typescript title="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);
  }
}
```

```typescript title="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();
  });
});
```

- **Add the library** with [`ng generate @blotch/angular-lynx:add-testing`](/api/schematics.md#add-testing).
- **Run the tests** with `ng test`. The [unit-test builder](/api/build/index.md#unit-test) loads the library's setup, so there's no setup file to write.

## API

| Page                                                                    | What it covers                                                                  |
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| [`render()`](/api/testing-library/render.md)                            | `render()`, `renderDirective()`, `cleanup()`, `waitForUpdate()` and their types |
| [Element queries](/api/testing-library/queries.md)                      | `screen`, `within()`, `queries`, `*ByRole` and `*ByAccessibilityLabel`          |
| [`fireEvent`](/api/testing-library/fire-event.md)                       | `fireEvent()`, its arguments and bubbling, and `eventMap`                       |
| [Event reference](/api/testing-library/event-reference.md)              | Every `fireEvent` method, and the template binding it runs                      |
| [Device fakes](/api/testing-library/fakes/index.md)                     | How the fakes work, and which function fakes each service                       |
| [Device and host](/api/testing-library/fakes/device.md)                 | App state, network, Android's back button                                       |
| [Bluetooth, NFC and Wi-Fi](/api/testing-library/fakes/connectivity.md)  | Bluetooth LE devices, NFC tags, Wi-Fi networks                                  |
| [Sensors and audio](/api/testing-library/fakes/sensors.md)              | Location, motion, biometrics, audio recorder, audio player                      |
| [Camera, photos and files](/api/testing-library/fakes/media.md)         | Image picker, barcode scanner, photo library, file picker                       |
| [Contacts and calendar](/api/testing-library/fakes/people.md)           | The address book, the contact picker, the calendar's event editor               |
| [Sharing and links](/api/testing-library/fakes/sharing.md)              | Opened links, incoming links, shortcuts, shares to the app                      |
| [Sign-in, reviews and tracking](/api/testing-library/fakes/accounts.md) | Sign 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](/api/testing-library/fakes/index.md).

`ng test` loads it for you.

## Re-exports

| Export         | From                   | Description                                                               |
| -------------- | ---------------------- | ------------------------------------------------------------------------- |
| `ComponentRef` | `@angular/core` (type) | The type of [`componentRef`](/api/testing-library/render.md#renderresult) |

## Related

- [Testing](/guide/testing/index.md)
- [Testing patterns](/guide/testing/patterns.md)
- [Event reference](/api/testing-library/event-reference.md)
