Ember-semantic-test-helpers
Exposes semantic helpers based on https://github.com/emberjs/rfcs/pull/327 rfc
This addon defines a few ux/accisabile semantic helpers.
High level
function click(label: string): Promise<void>
Internally uses findButton
, then invokes click
from ember-test-helpers
function select(label: string, value): Promise<void>
Internally uses findControl
, then invokes a custom select function that will select based on label instead of value
function toggle(label: string): Promise<void>
Internally uses findControl
, then invokes click
from ember-test-helpers
on that control
function fillIn(label: string, value): Promise<void>
Internally uses findControl
, then invokes fillIn
from ember-test-helpers
on that control
low level
function findButton(label: string, value): Promise<void>
Searches the page for the following
'button',
'a',
'[role="button"]',
'input[type="reset"]',
'input[type="button"]',
'input[type="submit"]',
'[role="link"]',
'[role="menuitem"]',
Then computes the label for each control using Text alternative spec either returns the result or an ergonomic error
function findControl(label: string, value): Promise<void>
Searches the page for the following
let inputs = [
'input',
'textarea',
'[role="slider"]',
'[role="spinbutton"]',
'[role="textbox"]',
'[contenteditable="true"]',
]
let toggles = [
'[role="checkbox"]',
]
let selectables = [
'select',
'[role="listbox"]',
'[role="radiogroup"]',
]
Then computes the label for each control using Text alternative spec either returns the result or an ergonomic error
ember install ember-semantic-test-helpers
Usage
import { click, fillIn, select, toggle } from 'ember-semantic-test-helpers/test-support';
test('Logging in', async function(assert) {
await visit('/login');
await fillIn('Email', 'alice@example.com');
await fillIn('Password', 'topsecret');
await select('Some lable targeting a select', 123)
await toggle('keep me logged in')
await click('Log in');
});
Contributing
Installation
git clone <repository-url>
cd my-addon
npm install
Linting
npm run lint:js
npm run lint:js -- --fix
Running tests
ember test
– Runs the test suite on the current Ember versionember test --server
– Runs the test suite in "watch mode"ember try:each
– Runs the test suite against multiple Ember versions
Running the dummy application
For more information on using ember-cli, visit https://ember-cli.com/.
License
This project is licensed under the MIT License.