Skip to content

Commit 53f7ab3

Browse files
authored
improvement: Typescript typings (#3855)
* Codecept.run() should return promise * Pause accepts optional support object * executeScript can return a value * Update docs * Expand pause param type * Simplify pause param type
1 parent 4c996f5 commit 53f7ab3

File tree

10 files changed

+117
-102
lines changed

10 files changed

+117
-102
lines changed

docs/helpers/Nightmare.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,10 @@ let val = await I.executeAsyncScript(function(url, done) {
379379
#### Parameters
380380
381381
- `args` **...any** to be passed to function.
382-
⚠️ returns a _promise_ which is synchronized internally by recorderWrapper for asynchronous [evaluate][7].
383-
Unlike NightmareJS implementation calling `done` will return its first argument.
384-
- `fn` **([string][3] | [function][8])** function to be executed in browser context.
382+
- `fn` **([string][3] | [function][7])** function to be executed in browser context.
383+
384+
Returns **[Promise][8]<any>** script return value⚠️ returns a _promise_ which is synchronized internally by recorderWrapper for asynchronous [evaluate][9].
385+
Unlike NightmareJS implementation calling `done` will return its first argument.
385386
386387
### executeScript
387388
@@ -412,8 +413,9 @@ let date = await I.executeScript(function(el) {
412413
#### Parameters
413414
414415
- `args` **...any** to be passed to function.
415-
⚠️ returns a _promise_ which is synchronized internally by recorderWrapper for synchronous [evaluate][7]
416-
- `fn` **([string][3] | [function][8])** function to be executed in browser context.
416+
- `fn` **([string][3] | [function][7])** function to be executed in browser context.
417+
418+
Returns **[Promise][8]<any>** script return value⚠️ returns a _promise_ which is synchronized internally by recorderWrapper for synchronous [evaluate][9]
417419
418420
### fillField
419421
@@ -452,7 +454,7 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
452454
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
453455
- `attr` **[string][3]** attribute name.
454456
455-
Returns **[Promise][9]<[string][3]>** attribute value
457+
Returns **[Promise][8]<[string][3]>** attribute value
456458
457459
### grabAttributeFromAll
458460
@@ -468,7 +470,7 @@ let hints = await I.grabAttributeFromAll('.tooltip', 'title');
468470
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
469471
- `attr` **[string][3]** attribute name.
470472
471-
Returns **[Promise][9]<[Array][10]<[string][3]>>** attribute value
473+
Returns **[Promise][8]<[Array][10]<[string][3]>>** attribute value
472474
473475
### grabCookie
474476
@@ -485,7 +487,7 @@ assert(cookie.value, '123456');
485487
486488
- `name` **[string][3]?** cookie name.
487489
488-
Returns **([Promise][9]<[string][3]> | [Promise][9]<[Array][10]<[string][3]>>)** attribute valueCookie in JSON format. If name not passed returns all cookies for this domain.Multiple cookies can be received by passing query object `I.grabCookie({ secure: true});`. If you'd like get all cookies for all urls, use: `.grabCookie({ url: null }).`
490+
Returns **([Promise][8]<[string][3]> | [Promise][8]<[Array][10]<[string][3]>>)** attribute valueCookie in JSON format. If name not passed returns all cookies for this domain.Multiple cookies can be received by passing query object `I.grabCookie({ secure: true});`. If you'd like get all cookies for all urls, use: `.grabCookie({ url: null }).`
489491
490492
### grabCssPropertyFrom
491493
@@ -502,7 +504,7 @@ const value = await I.grabCssPropertyFrom('h3', 'font-weight');
502504
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
503505
- `cssProperty` **[string][3]** CSS property name.
504506
505-
Returns **[Promise][9]<[string][3]>** CSS value
507+
Returns **[Promise][8]<[string][3]>** CSS value
506508
507509
### grabCurrentUrl
508510
@@ -514,7 +516,7 @@ let url = await I.grabCurrentUrl();
514516
console.log(`Current URL is [${url}]`);
515517
```
516518
517-
Returns **[Promise][9]<[string][3]>** current URL
519+
Returns **[Promise][8]<[string][3]>** current URL
518520
519521
### grabElementBoundingRect
520522
@@ -542,7 +544,7 @@ const width = await I.grabElementBoundingRect('h3', 'width');
542544
- `prop`
543545
- `elementSize` **[string][3]?** x, y, width or height of the given element.
544546
545-
Returns **([Promise][9]<DOMRect> | [Promise][9]<[number][11]>)** Element bounding rectangle
547+
Returns **([Promise][8]<DOMRect> | [Promise][8]<[number][11]>)** Element bounding rectangle
546548
547549
### grabHAR
548550
@@ -568,7 +570,7 @@ let postHTML = await I.grabHTMLFrom('#post');
568570
- `locator`
569571
- `element` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
570572
571-
Returns **[Promise][9]<[string][3]>** HTML code for an element
573+
Returns **[Promise][8]<[string][3]>** HTML code for an element
572574
573575
### grabHTMLFromAll
574576
@@ -584,7 +586,7 @@ let postHTMLs = await I.grabHTMLFromAll('.post');
584586
- `locator`
585587
- `element` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
586588
587-
Returns **[Promise][9]<[Array][10]<[string][3]>>** HTML code for an element
589+
Returns **[Promise][8]<[Array][10]<[string][3]>>** HTML code for an element
588590
589591
### grabNumberOfVisibleElements
590592
@@ -599,7 +601,7 @@ let numOfElements = await I.grabNumberOfVisibleElements('p');
599601
600602
- `locator` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
601603
602-
Returns **[Promise][9]<[number][11]>** number of visible elements
604+
Returns **[Promise][8]<[number][11]>** number of visible elements
603605
604606
### grabPageScrollPosition
605607
@@ -610,7 +612,7 @@ Resumes test execution, so **should be used inside an async function with `await
610612
let { x, y } = await I.grabPageScrollPosition();
611613
```
612614
613-
Returns **[Promise][9]<PageScrollPosition>** scroll position
615+
Returns **[Promise][8]<PageScrollPosition>** scroll position
614616
615617
### grabTextFrom
616618
@@ -627,7 +629,7 @@ If multiple elements found returns first element.
627629
628630
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
629631
630-
Returns **[Promise][9]<[string][3]>** attribute value
632+
Returns **[Promise][8]<[string][3]>** attribute value
631633
632634
### grabTextFromAll
633635
@@ -642,7 +644,7 @@ let pins = await I.grabTextFromAll('#pin li');
642644
643645
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
644646
645-
Returns **[Promise][9]<[Array][10]<[string][3]>>** attribute value
647+
Returns **[Promise][8]<[Array][10]<[string][3]>>** attribute value
646648
647649
### grabTitle
648650
@@ -653,7 +655,7 @@ Resumes test execution, so **should be used inside async with `await`** operator
653655
let title = await I.grabTitle();
654656
```
655657
656-
Returns **[Promise][9]<[string][3]>** title
658+
Returns **[Promise][8]<[string][3]>** title
657659
658660
### grabValueFrom
659661
@@ -669,7 +671,7 @@ let email = await I.grabValueFrom('input[name=email]');
669671
670672
- `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
671673
672-
Returns **[Promise][9]<[string][3]>** attribute value
674+
Returns **[Promise][8]<[string][3]>** attribute value
673675
674676
### grabValueFromAll
675677
@@ -684,7 +686,7 @@ let inputs = await I.grabValueFromAll('//form/input');
684686
685687
- `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
686688
687-
Returns **[Promise][9]<[Array][10]<[string][3]>>** attribute value
689+
Returns **[Promise][8]<[Array][10]<[string][3]>>** attribute value
688690
689691
### haveHeader
690692
@@ -1159,7 +1161,7 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and
11591161
11601162
#### Parameters
11611163
1162-
- `fn` **([string][3] | [function][8])** to be executed in browser context.
1164+
- `fn` **([string][3] | [function][7])** to be executed in browser context.
11631165
- `argsOrSec` **([Array][10]<any> | [number][11])?** (optional, `1` by default) arguments for function or seconds.
11641166
- `sec` **[number][11]?** (optional, `1` by default) time in seconds to wait
11651167
⚠️ returns a _promise_ which is synchronized internally by recorder
@@ -1239,11 +1241,11 @@ I.waitToHide('#popup');
12391241
12401242
[6]: https://vuejs.org/v2/api/#Vue-nextTick
12411243
1242-
[7]: https://github.com/segmentio/nightmare#evaluatefn-arg1-arg2
1244+
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
12431245
1244-
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
1246+
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
12451247
1246-
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
1248+
[9]: https://github.com/segmentio/nightmare#evaluatefn-arg1-arg2
12471249
12481250
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
12491251

docs/helpers/Protractor.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ let val = await I.executeAsyncScript(function(url, done) {
530530
531531
- `fn` **([string][9] | [function][12])** function to be executed in browser context.
532532
- `args` **...any** to be passed to function.
533-
⚠️ returns a _promise_ which is synchronized internally by recorder
533+
534+
Returns **[Promise][13]<any>** script return value⚠️ returns a _promise_ which is synchronized internally by recorder
534535
535536
### executeScript
536537
@@ -562,7 +563,8 @@ let date = await I.executeScript(function(el) {
562563
563564
- `fn` **([string][9] | [function][12])** function to be executed in browser context.
564565
- `args` **...any** to be passed to function.
565-
⚠️ returns a _promise_ which is synchronized internally by recorder
566+
567+
Returns **[Promise][13]<any>** script return value⚠️ returns a _promise_ which is synchronized internally by recorder
566568
567569
### fillField
568570

0 commit comments

Comments
 (0)