Skip to content

Commit eddb7cb

Browse files
atramaAndrew A Lee
authored and
Andrew A Lee
committed
add async/await syntax to readme (closes #95) (#96)
add async/await syntax to readme
1 parent 85dde52 commit eddb7cb

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

README.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ import a11yAudit from 'ember-a11y-testing/test-support/audit';
4747

4848
// ...elided for brevity
4949

50+
test('Some test case', async function(assert) {
51+
await visit('/');
52+
await a11yAudit();
53+
assert.ok(true, 'no a11y errors found!');
54+
});
55+
```
56+
57+
If your app does now allow async/await, you will need to use the the andThen() helper and a regular function (as opposed to `async function`).
58+
59+
```javascript
60+
import a11yAudit from 'ember-a11y-testing/test-support/audit';
61+
62+
// ...elided for brevity
63+
5064
test('Some test case', function(assert) {
5165
visit('/');
5266
a11yAudit();
@@ -59,7 +73,7 @@ either a selector string or an HTML element. You can also provide a secondary
5973
parameter to specify axe-core options:
6074

6175
```js
62-
test('Some test case', function(assert) {
76+
test('Some test case', async function(assert) {
6377
let axeOptions = {
6478
rules: {
6579
'button-name': {
@@ -68,16 +82,16 @@ test('Some test case', function(assert) {
6882
}
6983
};
7084

71-
visit('/');
72-
a11yAudit(axeOptions);
73-
andThen(() => assert.ok(true, 'no a11y errors found!'));
85+
await visit('/');
86+
await a11yAudit(axeOptions);
87+
assert.ok(true, 'no a11y errors found!');
7488
});
7589
```
7690

7791
Or specify options as a single argument:
7892

7993
```js
80-
test('Some test case', function(assert) {
94+
test('Some test case', async function(assert) {
8195
let axeOptions = {
8296
rules: {
8397
'button-name': {
@@ -86,9 +100,9 @@ test('Some test case', function(assert) {
86100
}
87101
};
88102

89-
visit('/');
90-
a11yAudit('.modal', axeOptions);
91-
andThen(() => assert.ok(true, 'no a11y errors found!'));
103+
await visit('/');
104+
await a11yAudit('.modal', axeOptions);
105+
assert.ok(true, 'no a11y errors found!');
92106
});
93107
```
94108

@@ -130,10 +144,10 @@ nightly build jobs.
130144
```javascript
131145
import a11yAuditIf from 'ember-a11y-testing/test-support/audit-if';
132146

133-
test('Some test case', function(assert) {
134-
visit('/');
135-
a11yAuditIf(); // Only runs when enableA11yAudit=true is in the URL
136-
andThen(() => assert.ok(true, 'no a11y errors found!'));
147+
test('Some test case', await function(assert) {
148+
await visit('/');
149+
await a11yAuditIf(); // Only runs when enableA11yAudit=true is in the URL
150+
assert.ok(true, 'no a11y errors found!');
137151
});
138152
```
139153

0 commit comments

Comments
 (0)