Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 39f0615

Browse files
sjelincnishina
authored andcommitted
chore(examples): update async/await example with better info (#3693)
1 parent 6ebee72 commit 39f0615

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

Diff for: exampleTypescript/asyncAwait/README.md

+29-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1-
`async`/`await` in Protractor
2-
=============================
3-
4-
`async`/`await` is a feature that may or may not be added to javascript in
5-
the future. It is currently accessible via typescript if you compile using
6-
`tsc -t ES2015 <files>`. Protractor supports returning a promise at the end of
7-
an `it()` block, so it indirectly supports `async`/`await` (so long as your
8-
programming environment supports it).
1+
`async`/`await` and the Web Driver Control Flow
2+
===============================================
3+
4+
The Web Driver Control Flow is used to synchronize your commands so they reach
5+
the browser in the correct order (see [control-flow.md](
6+
../../docs/control-flow.md) for details). In the future, the control flow is
7+
being removed, however (see [github issue](
8+
https://github.com/SeleniumHQ/selenium/issues/2969) for details). Instead of
9+
the control flow, you can synchronize your commands with promise chaining or the
10+
upcomming ES7 feature `async`/`await`. However, you cannot use a mix of
11+
`async`/`await` and the control flow: `async`/`await` causes the control flow to
12+
become unreliable (see [github issue](
13+
https://github.com/SeleniumHQ/selenium/issues/3037)). So if you `async`/`await`
14+
anywhere in a spec, you should use `await` or promise chaining to handle all
15+
asynchronous activity (e.g. any command interacting with the browser) for the
16+
rest of that test.
17+
18+
In the near future there will be an option to disable the Web Driver control
19+
flow entierly (see https://github.com/angular/protractor/issues/3691). If you
20+
are using `async`/`await`, it is highly recommended that you disable the Web
21+
Driver control flow.
22+
23+
24+
Compiling `async`/`await` syntax
25+
================================
26+
27+
`async`/`await` syntax is currently accessible via typescript if you compile
28+
using `tsc -t ES2015 <files>`. You can also compile it using [regenerator](
29+
https://github.com/facebook/regenerator).

Diff for: exampleTypescript/asyncAwait/spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Same process for importing and compiling at ../spec.ts, except you need to
2-
// pass the `-t ES2015` flag to `tsc`.
1+
// See README.md for important details.
32
import {browser, element, by, By, $, $$, ExpectedConditions} from 'protractor';
43

54
describe('async function', function() {

0 commit comments

Comments
 (0)