click()
Simulates a user click on an element and waits for the app to settle.
Syntax
await click(target) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
target | string | Element | No | A selector or element to click. |
Returns
Promise<void> — Resolves once the resulting render settles.
Examples
import { render, click } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
test('toggles on click', async function (assert) {
await render(hbs`<Toggle />`);
await click('[data-test-toggle]');
assert.dom('[data-test-state]').hasText('On');
});
Notes
click() fires the full event sequence (mousedown, focus, mouseup, click)
and awaits settledness. Prefer data-test-* attributes over CSS selectors
so tests do not break on styling changes.