selenium-webdriver 3.3.0 → 4.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGES.md +273 -0
  2. package/NOTICE +1 -1
  3. package/README.md +28 -36
  4. package/chrome.js +221 -146
  5. package/edge.js +43 -118
  6. package/example/chrome_android.js +8 -9
  7. package/example/chrome_mobile_emulation.js +9 -10
  8. package/example/firefox_channels.js +23 -19
  9. package/example/google_search.js +3 -3
  10. package/example/google_search_test.js +39 -27
  11. package/example/headless.js +55 -0
  12. package/example/logging.js +40 -7
  13. package/firefox.js +769 -0
  14. package/http/index.js +41 -4
  15. package/http/util.js +11 -6
  16. package/ie.js +57 -98
  17. package/index.js +182 -115
  18. package/io/index.js +59 -0
  19. package/io/zip.js +214 -0
  20. package/jasmine.json +11 -0
  21. package/lib/actions.js +68 -63
  22. package/lib/atoms/get-attribute.js +9 -0
  23. package/lib/atoms/is-displayed.js +73 -78
  24. package/lib/by.js +9 -1
  25. package/lib/capabilities.js +303 -201
  26. package/lib/command.js +28 -50
  27. package/lib/error.js +113 -42
  28. package/lib/http.js +167 -135
  29. package/lib/input.js +1044 -8
  30. package/lib/promise.js +222 -3331
  31. package/lib/proxy.js +134 -39
  32. package/lib/test/bootstrap_jasmine.js +28 -0
  33. package/lib/test/data/actions/click.html +24 -0
  34. package/lib/test/data/actions/drag.html +77 -0
  35. package/lib/test/data/actions/record_click.html +21 -0
  36. package/lib/test/data/chrome/download.html +2 -0
  37. package/lib/test/data/click_tests/disabled_element.html +12 -0
  38. package/lib/test/data/content-editable.html +10 -0
  39. package/lib/test/data/firefox/webextension.xpi +0 -0
  40. package/lib/test/data/inputs.html +42 -0
  41. package/lib/test/data/key_logger.html +34 -0
  42. package/lib/test/data/nestedElements.html +10 -1
  43. package/lib/test/data/scrolling_tests/page_with_partially_hidden_element.html +14 -0
  44. package/lib/test/data/selectPage.html +12 -0
  45. package/lib/test/data/simpleTest.html +5 -0
  46. package/lib/test/data/single_text_input.html +12 -0
  47. package/lib/test/data/upload_invisible.html +45 -0
  48. package/lib/test/fileserver.js +23 -19
  49. package/lib/test/index.js +30 -244
  50. package/lib/test/resources.js +0 -1
  51. package/lib/webdriver.js +770 -939
  52. package/net/index.js +21 -25
  53. package/net/portprober.js +51 -68
  54. package/package.json +6 -4
  55. package/remote/index.js +18 -30
  56. package/safari.js +42 -129
  57. package/test/actions_test.js +173 -18
  58. package/test/builder_test.js +106 -0
  59. package/test/chrome/devtools_test.js +93 -0
  60. package/test/chrome/options_test.js +48 -154
  61. package/test/chrome/service_test.js +7 -7
  62. package/test/cookie_test.js +77 -63
  63. package/test/element_finding_test.js +206 -201
  64. package/test/execute_script_test.js +115 -114
  65. package/test/fingerprint_test.js +16 -15
  66. package/test/firefox_test.js +251 -0
  67. package/test/http/http_test.js +18 -1
  68. package/test/http/util_test.js +2 -2
  69. package/test/{io_test.js → io/io_test.js} +40 -1
  70. package/test/io/zip_test.js +127 -0
  71. package/test/lib/by_test.js +21 -0
  72. package/test/lib/error_test.js +55 -8
  73. package/test/lib/http_test.js +18 -130
  74. package/test/lib/input_test.js +1379 -0
  75. package/test/lib/promise_test.js +473 -908
  76. package/test/lib/webdriver_test.js +357 -825
  77. package/test/logging_test.js +37 -43
  78. package/test/page_loading_test.js +70 -86
  79. package/test/proxy_test.js +64 -72
  80. package/test/rect_test.js +14 -25
  81. package/test/remote_test.js +13 -32
  82. package/test/safari_test.js +7 -71
  83. package/test/stale_element_test.js +20 -23
  84. package/test/tag_name_test.js +10 -9
  85. package/test/upload_test.js +27 -35
  86. package/test/window_test.js +72 -85
  87. package/testing/index.js +386 -315
  88. package/.npmignore +0 -2
  89. package/example/async_await_test.js +0 -68
  90. package/example/google_search_generator.js +0 -50
  91. package/example/parallel_flows.js +0 -54
  92. package/firefox/binary.js +0 -344
  93. package/firefox/extension.js +0 -187
  94. package/firefox/index.js +0 -722
  95. package/firefox/profile.js +0 -430
  96. package/lib/atoms/getAttribute.js +0 -12
  97. package/lib/events.js +0 -210
  98. package/lib/firefox/webdriver.json +0 -70
  99. package/lib/firefox/webdriver.xpi +0 -0
  100. package/lib/test/data/firefox/jetpack-sample.xpi +0 -0
  101. package/lib/test/data/firefox/sample.xpi +0 -0
  102. package/lib/test/promise.js +0 -79
  103. package/opera.js +0 -405
  104. package/phantomjs.js +0 -282
  105. package/test/firefox/extension_test.js +0 -96
  106. package/test/firefox/firefox_test.js +0 -226
  107. package/test/firefox/profile_test.js +0 -185
  108. package/test/lib/events_test.js +0 -177
  109. package/test/lib/promise_aplus_test.js +0 -78
  110. package/test/lib/promise_error_test.js +0 -884
  111. package/test/lib/promise_flow_test.js +0 -2288
  112. package/test/lib/promise_generator_test.js +0 -310
  113. package/test/phantomjs/execute_phantomjs_test.js +0 -59
  114. package/test/session_test.js +0 -54
  115. package/test/testing/assert_test.js +0 -373
  116. package/test/testing/index_test.js +0 -224
  117. package/testing/assert.js +0 -378
@@ -1,373 +0,0 @@
1
- // Licensed to the Software Freedom Conservancy (SFC) under one
2
- // or more contributor license agreements. See the NOTICE file
3
- // distributed with this work for additional information
4
- // regarding copyright ownership. The SFC licenses this file
5
- // to you under the Apache License, Version 2.0 (the
6
- // "License"); you may not use this file except in compliance
7
- // with the License. You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing,
12
- // software distributed under the License is distributed on an
13
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- // KIND, either express or implied. See the License for the
15
- // specific language governing permissions and limitations
16
- // under the License.
17
-
18
- 'use strict';
19
-
20
- const assert = require('../../testing/assert');
21
-
22
- const AssertionError = require('assert').AssertionError;
23
- const assertTrue = require('assert').ok;
24
- const assertEqual = require('assert').equal;
25
- const assertThrows = require('assert').throws;
26
- const fail = require('assert').fail;
27
-
28
-
29
- describe('assert', function() {
30
- describe('atLeast', function() {
31
- it('compares subject >= value', function() {
32
- assert(1).atLeast(0);
33
- assert(1).atLeast(1);
34
- assertThrows(() => assert(1).atLeast(2));
35
- });
36
-
37
- it('accepts failure message', function() {
38
- assertThrows(
39
- () => assert(1).atLeast(2, 'hi there!'),
40
- (error) => error.message.indexOf('hi there') != -1);
41
- });
42
-
43
- it('fails if given a non-numeric subject', function() {
44
- assertThrows(() => assert('a').atLeast(1));
45
- });
46
-
47
- it('fails if given a non-numeric bound', function() {
48
- assertThrows(() => assert(1).atLeast('a'));
49
- });
50
-
51
- it('waits for promised subject', function() {
52
- return assert(Promise.resolve(123)).atLeast(100);
53
- });
54
-
55
- it('waits for promised subject (with failure)', function() {
56
- return assert(Promise.resolve(100))
57
- .atLeast(123)
58
- .then(() => fail('should have failed'), function(e) {
59
- assertInstanceOf(AssertionError, e);
60
- assertEqual('100 >= 123', e.message);
61
- });
62
- });
63
- });
64
-
65
- describe('atMost', function() {
66
- it('compares subject <= value', function() {
67
- assertThrows(() => assert(1).atMost(0));
68
- assert(1).atMost(1);
69
- assert(1).atMost(2);
70
- });
71
-
72
- it('accepts failure message', function() {
73
- assertThrows(
74
- () => assert(1).atMost(0, 'hi there!'),
75
- (error) => error.message.indexOf('hi there!') != -1);
76
- });
77
-
78
- it('fails if given a non-numeric subject', function() {
79
- assertThrows(() => assert(1).atMost('a'));
80
- });
81
-
82
- it('fails if given a non-numeric bound', function() {
83
- assertThrows(() => assert('a').atMost(1));
84
- });
85
-
86
- it('waits for promised subject', function() {
87
- return assert(Promise.resolve(100)).atMost(123);
88
- });
89
-
90
- it('waits for promised subject (with failure)', function() {
91
- return assert(Promise.resolve(123))
92
- .atMost(100)
93
- .then(() => fail('should have failed'), function(e) {
94
- assertInstanceOf(AssertionError, e);
95
- assertEqual('123 <= 100', e.message);
96
- });
97
- });
98
- });
99
-
100
- describe('greaterThan', function() {
101
- it('compares subject > value', function() {
102
- assertThrows(() => assert(1).greaterThan(1));
103
- assertThrows(() => assert(1).greaterThan(2));
104
- assert(2).greaterThan(1);
105
- });
106
-
107
- it('accepts failure message', function() {
108
- assertThrows(
109
- () => assert(0).greaterThan(1, 'hi there!'),
110
- (error) => error.message.indexOf('hi there!') != -1);
111
- });
112
-
113
- it('fails if given a non-numeric subject', function() {
114
- assertThrows(() => assert('a').atMost(1));
115
- });
116
-
117
- it('fails if given a non-numeric bound', function() {
118
- assertThrows(() => assert(1).atMost('a'));
119
- });
120
-
121
- it('waits for promised subject', function() {
122
- return assert(Promise.resolve(123)).greaterThan(100);
123
- });
124
-
125
- it('waits for promised subject (with failure)', function() {
126
- return assert(Promise.resolve(100))
127
- .greaterThan(123)
128
- .then(() => fail('should have failed'), function(e) {
129
- assertInstanceOf(AssertionError, e);
130
- assertEqual('100 > 123', e.message);
131
- });
132
- });
133
- });
134
-
135
- describe('lessThan', function() {
136
- it('compares subject < value', function() {
137
- assertThrows(() => assert(1).lessThan(0));
138
- assertThrows(() => assert(1).lessThan(1));
139
- assert(1).lessThan(2);
140
- });
141
-
142
- it('accepts failure message', function() {
143
- assertThrows(
144
- () => assert(1).lessThan(0, 'hi there!'),
145
- (error) => error.message.indexOf('hi there!') != -1);
146
- });
147
-
148
- it('fails if given a non-numeric subject', function() {
149
- assertThrows(() => assert('a').lessThan(1));
150
- });
151
-
152
- it('fails if given a non-numeric bound', function() {
153
- assertThrows(() => assert(1).lessThan('a'));
154
- });
155
-
156
- it('waits for promised subject', function() {
157
- return assert(Promise.resolve(100)).lessThan(123);
158
- });
159
-
160
- it('waits for promised subject (with failure)', function() {
161
- return assert(Promise.resolve(123))
162
- .lessThan(100)
163
- .then(() => fail('should have failed'), function(e) {
164
- assertInstanceOf(AssertionError, e);
165
- assertEqual('123 < 100', e.message);
166
- });
167
- });
168
- });
169
-
170
- describe('closeTo', function() {
171
- it('accepts values within epislon of target', function() {
172
- assert(123).closeTo(123, 0);
173
- assert(123).closeTo(124, 1);
174
- assert(125).closeTo(124, 1);
175
-
176
- assertThrows(() => assert(123).closeTo(125, .1));
177
- assertThrows(() => assert(1./3).closeTo(.8, .01));
178
- });
179
-
180
- it('waits for promised values', function() {
181
- let p = new Promise(resolve => setTimeout(() => resolve(123), 10));
182
- return assert(p).closeTo(124, 1);
183
- });
184
- });
185
-
186
- describe('instanceOf', function() {
187
- it('works with direct instances', function() {
188
- assert(Error('foo')).instanceOf(Error);
189
- });
190
-
191
- it('works with sub-types', function() {
192
- assert(TypeError('foo')).instanceOf(Error);
193
- });
194
-
195
- it('parent types are not instances of sub-types', function() {
196
- assertThrows(() => assert(Error('foo')).instanceOf(TypeError));
197
- });
198
- });
199
-
200
- describe('isNull', function() {
201
- it('normal case', function() {
202
- assert(null).isNull();
203
- assertThrows(() => assert(1).isNull());
204
- });
205
-
206
- it('handles promised values', function() {
207
- let p = new Promise(function(f) {
208
- setTimeout(() => f(null), 10);
209
- });
210
- return assert(p).isNull();
211
- });
212
-
213
- it('does not match on undefined', function() {
214
- assertThrows(() => assert(void(0)).isNull());
215
- })
216
- });
217
-
218
- describe('isUndefined', function() {
219
- it('normal case', function() {
220
- assert(void(0)).isUndefined();
221
- assertThrows(() => assert(1).isUndefined());
222
- });
223
-
224
- it('handles promised values', function() {
225
- let p = new Promise(function(f) {
226
- setTimeout(() => f(void(0)), 10);
227
- });
228
- return assert(p).isUndefined();
229
- });
230
-
231
- it('does not match on null', function() {
232
- assertThrows(() => assert(null).isUndefined());
233
- })
234
- });
235
-
236
- describe('contains', function() {
237
- it('works with strings', function() {
238
- assert('abc').contains('a');
239
- assert('abc').contains('ab');
240
- assert('abc').contains('abc');
241
- assert('abc').contains('bc');
242
- assert('abc').contains('c');
243
- assertThrows(() => assert('abc').contains('d'));
244
- });
245
-
246
- it('works with arrays', function() {
247
- assert([1, 2, 3]).contains(1);
248
- assert([1, 2, 3]).contains(2);
249
- assert([1, 2, 3]).contains(3);
250
- assertThrows(() => assert([1, 2]).contains(3));
251
- });
252
-
253
- it('works with maps', function() {
254
- let m = new Map;
255
- m.set(1, 2);
256
- assert(m).contains(1);
257
- assertThrows(() => assert(m).contains(2));
258
- });
259
-
260
- it('works with sets', function() {
261
- let s = new Set;
262
- s.add(1);
263
- assert(s).contains(1);
264
- assertThrows(() => assert(s).contains(2));
265
- });
266
-
267
- it('requires an array, string, map, or set subject', function() {
268
- assertThrows(() => assert(123).contains('a'));
269
- });
270
- });
271
-
272
- describe('endsWith', function() {
273
- it('works', function() {
274
- assert('abc').endsWith('abc');
275
- assert('abc').endsWith('bc');
276
- assert('abc').endsWith('c');
277
- assertThrows(() => assert('abc').endsWith('d'));
278
- })
279
- });
280
-
281
- describe('startsWith', function() {
282
- it('works', function() {
283
- assert('abc').startsWith('abc');
284
- assert('abc').startsWith('ab');
285
- assert('abc').startsWith('a');
286
- assertThrows(() => assert('abc').startsWith('d'));
287
- })
288
- });
289
-
290
- describe('matches', function() {
291
- it('requires a regex value', function() {
292
- assertThrows(() => assert('abc').matches(1234));
293
- });
294
-
295
- it('requires a string value', function() {
296
- assertThrows(() => assert(1234).matches(/abc/));
297
- });
298
-
299
- it('requires a string value (promise case)', function() {
300
- return assert(Promise.resolve(1234))
301
- .matches(/abc/)
302
- .then(fail, function(error) {
303
- assertEqual(
304
- 'Expected a string matching /abc/, got <1234> (number)',
305
- error.message);
306
- });
307
- });
308
-
309
- it('applies regex', function() {
310
- assert('abc').matches(/abc/);
311
- assertThrows(() => assert('def').matches(/abc/));
312
- });
313
- });
314
-
315
- describe('isTrue', function() {
316
- it('only accepts booleans', function() {
317
- assertThrows(() => assert(123).isTrue());
318
- });
319
-
320
- it('accepts true values', function() {
321
- assert(true).isTrue();
322
- assert(Boolean('abc')).isTrue();
323
- return assert(Promise.resolve(true)).isTrue();
324
- });
325
-
326
- it('rejects false values', function() {
327
- assertThrows(() => assert(false).isTrue());
328
- assertThrows(() => assert(Boolean(0)).isTrue());
329
- return assert(Promise.resolve(false)).isTrue()
330
- .then(fail, function() {/*no-op, ok*/});
331
- });
332
- });
333
-
334
- describe('isFalse', function() {
335
- it('only accepts booleans', function() {
336
- assertThrows(() => assert(123).isFalse());
337
- })
338
-
339
- it('accepts false values', function() {
340
- assert(false).isFalse();
341
- assert(Boolean('')).isFalse();
342
- return assert(Promise.resolve(false)).isFalse();
343
- });
344
-
345
- it('rejects true values', function() {
346
- assertThrows(() => assert(true).isFalse());
347
- assertThrows(() => assert(Boolean(1)).isFalse());
348
- return assert(Promise.resolve(true)).isFalse()
349
- .then(fail, function() {/*no-op, ok*/});
350
- });
351
- });
352
-
353
- describe('isEqualTo', function() {
354
- it('is strict equality', function() {
355
- assert('abc').isEqualTo('abc');
356
- assert('abc').equals('abc');
357
- assert('abc').equalTo('abc');
358
- assertThrows(() => assert('1').isEqualTo(1));
359
- });
360
- });
361
-
362
- describe('notEqualTo', function() {
363
- it('tests strict equality', function() {
364
- assert('1').notEqualTo(1);
365
- assert(1).notEqualTo('1');
366
- assertThrows(() => assert('abc').notEqualTo('abc'));
367
- });
368
- });
369
-
370
- function assertInstanceOf(ctor, value) {
371
- assertTrue(value instanceof ctor);
372
- }
373
- });
@@ -1,224 +0,0 @@
1
- // Licensed to the Software Freedom Conservancy (SFC) under one
2
- // or more contributor license agreements. See the NOTICE file
3
- // distributed with this work for additional information
4
- // regarding copyright ownership. The SFC licenses this file
5
- // to you under the Apache License, Version 2.0 (the
6
- // "License"); you may not use this file except in compliance
7
- // with the License. You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing,
12
- // software distributed under the License is distributed on an
13
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- // KIND, either express or implied. See the License for the
15
- // specific language governing permissions and limitations
16
- // under the License.
17
-
18
- 'use strict';
19
-
20
- const assert = require('assert');
21
- const promise = require('../..').promise;
22
- const {enablePromiseManager} = require('../../lib/test/promise');
23
-
24
-
25
- var test = require('../../testing');
26
-
27
- describe('Mocha Integration', function() {
28
-
29
- describe('beforeEach properly binds "this"', function() {
30
- beforeEach(function() { this.x = 1; });
31
- test.beforeEach(function() { this.x = 2; });
32
- it('', function() { assert.equal(this.x, 2); });
33
- });
34
-
35
- describe('afterEach properly binds "this"', function() {
36
- it('', function() { this.x = 1; });
37
- test.afterEach(function() { this.x = 2; });
38
- afterEach(function() { assert.equal(this.x, 2); });
39
- });
40
-
41
- describe('it properly binds "this"', function() {
42
- beforeEach(function() { this.x = 1; });
43
- test.it('', function() { this.x = 2; });
44
- afterEach(function() { assert.equal(this.x, 2); });
45
- });
46
-
47
- enablePromiseManager(function() {
48
- describe('timeout handling', function() {
49
- describe('it does not reset the control flow on a non-timeout', function() {
50
- var flowReset = false;
51
-
52
- beforeEach(function() {
53
- flowReset = false;
54
- test.controlFlow().once(promise.ControlFlow.EventType.RESET, onreset);
55
- });
56
-
57
- test.it('', function() {
58
- this.timeout(100);
59
- return promise.delayed(50);
60
- });
61
-
62
- afterEach(function() {
63
- assert.ok(!flowReset);
64
- test.controlFlow().removeListener(
65
- promise.ControlFlow.EventType.RESET, onreset);
66
- });
67
-
68
- function onreset() {
69
- flowReset = true;
70
- }
71
- });
72
-
73
- describe('it resets the control flow after a timeout' ,function() {
74
- var timeoutErr, flowReset;
75
-
76
- beforeEach(function() {
77
- flowReset = false;
78
- test.controlFlow().once(promise.ControlFlow.EventType.RESET, onreset);
79
- });
80
-
81
- test.it('', function() {
82
- var callback = this.runnable().callback;
83
- var test = this;
84
- this.runnable().callback = function(err) {
85
- timeoutErr = err;
86
- // Reset our timeout to 0 so Mocha does not fail the test.
87
- test.timeout(0);
88
- // When we invoke the real callback, do not pass along the error so
89
- // Mocha does not fail the test.
90
- return callback.call(this);
91
- };
92
-
93
- test.timeout(50);
94
- return promise.defer().promise;
95
- });
96
-
97
- afterEach(function() {
98
- return Promise.resolve().then(function() {
99
- test.controlFlow().removeListener(
100
- promise.ControlFlow.EventType.RESET, onreset);
101
- assert.ok(flowReset, 'control flow was not reset after a timeout');
102
- });
103
- });
104
-
105
- function onreset() {
106
- flowReset = true;
107
- }
108
- });
109
- });
110
-
111
- describe('async "done" support', function() {
112
- this.timeout(2*1000);
113
-
114
- var waited = false;
115
- var DELAY = 100; // ms enough to notice
116
-
117
- // Each test asynchronously sets waited to true, so clear/check waited
118
- // before/after:
119
- beforeEach(function() {
120
- waited = false;
121
- });
122
-
123
- afterEach(function() {
124
- assert.strictEqual(waited, true);
125
- });
126
-
127
- // --- First, vanilla mocha "it" should support the "done" callback correctly.
128
-
129
- // This 'it' should block until 'done' is invoked
130
- it('vanilla delayed', function(done) {
131
- setTimeout(function delayedVanillaTimeout() {
132
- waited = true;
133
- done();
134
- }, DELAY);
135
- });
136
-
137
- // --- Now with the webdriver wrappers for 'it' should support the "done" callback:
138
-
139
- test.it('delayed', function(done) {
140
- assert(done);
141
- assert.strictEqual(typeof done, 'function');
142
- setTimeout(function delayedTimeoutCallback() {
143
- waited = true;
144
- done();
145
- }, DELAY);
146
- });
147
-
148
- // --- And test that the webdriver wrapper for 'it' works with a returned promise, too:
149
-
150
- test.it('delayed by promise', function() {
151
- var defer = promise.defer();
152
- setTimeout(function delayedPromiseCallback() {
153
- waited = true;
154
- defer.fulfill('ignored');
155
- });
156
- return defer.promise;
157
- });
158
- });
159
-
160
- describe('ControlFlow and "done" work together', function() {
161
- var flow, order;
162
- before(function() {
163
- order = [];
164
- flow = test.controlFlow();
165
- flow.execute(function() { order.push(1); });
166
- });
167
-
168
- test.it('control flow updates and async done', function(done) {
169
- flow.execute(function() { order.push(2); });
170
- flow.execute(function() { order.push(3); }).then(function() {
171
- order.push(4);
172
- });
173
- done();
174
- });
175
-
176
- after(function() {
177
- assert.deepEqual([1, 2, 3, 4], order);
178
- });
179
- });
180
- });
181
-
182
- describe('generator support', function() {
183
- let arr;
184
-
185
- beforeEach(() => arr = []);
186
- afterEach(() => assert.deepEqual(arr, [0, 1, 2, 3]));
187
-
188
- test.it('sync generator', function* () {
189
- arr.push(yield arr.length);
190
- arr.push(yield arr.length);
191
- arr.push(yield arr.length);
192
- arr.push(yield arr.length);
193
- });
194
-
195
- test.it('async generator', function* () {
196
- arr.push(yield Promise.resolve(arr.length));
197
- arr.push(yield Promise.resolve(arr.length));
198
- arr.push(yield Promise.resolve(arr.length));
199
- arr.push(yield Promise.resolve(arr.length));
200
- });
201
-
202
- test.it('generator returns promise', function*() {
203
- arr.push(yield Promise.resolve(arr.length));
204
- arr.push(yield Promise.resolve(arr.length));
205
- arr.push(yield Promise.resolve(arr.length));
206
- setTimeout(_ => arr.push(arr.length), 10);
207
- return new Promise((resolve) => setTimeout(_ => resolve(), 25));
208
- });
209
-
210
- describe('generator runs with proper "this" context', () => {
211
- before(function() { this.values = [0, 1, 2, 3]; });
212
- test.it('', function*() {
213
- arr = this.values;
214
- });
215
- });
216
-
217
- it('generator function must not take a callback', function() {
218
- arr = [0, 1, 2, 3]; // For teardown hook.
219
- assert.throws(_ => {
220
- test.it('', function*(done){});
221
- }, TypeError);
222
- });
223
- });
224
- });