Skip to content

Commit 4d9acf0

Browse files
authored
feat(ts): Add better tests for typescript (#2445)
* feat(ts): Add better tests for typescript * fix * fix * f * add more tests * add tests for helper * f * add tests * added methods * improve ts * improve typings * improve typings * remove appium jobs from PR * draft * fix * fix tests * add tests for all wdio methods * fix * fix tests * fix
1 parent 6d996b7 commit 4d9acf0

38 files changed

+772
-240
lines changed

.github/workflows/appium.yml

-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ on:
44
push:
55
branches:
66
- master
7-
pull_request:
8-
branches:
9-
- '**'
107

118
env:
129
CI: true

.github/workflows/dtslint.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Typings tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- '**'
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-18.04
14+
strategy:
15+
matrix:
16+
node-version: [12.x]
17+
steps:
18+
- uses: actions/checkout@v1
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v1
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- run: npm install
24+
- run: npm run def
25+
- run: npm run dtslint

docs/webapi/clearField.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ I.clearField('Email');
55
I.clearField('user[email]');
66
I.clearField('#email');
77
```
8-
@param {string|object} editable field located by label|name|CSS|XPath|strict locator.
8+
@param {LocatorOrString} editable field located by label|name|CSS|XPath|strict locator.

docs/webapi/closeCurrentTab.mustache

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Close current tab.
2+
3+
```js
4+
I.closeCurrentTab();
5+
```

docs/webapi/closeOtherTabs.mustache

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Close all tabs except for the current one.
2+
3+
4+
```js
5+
I.closeOtherTabs();
6+
```

docs/webapi/dragAndDrop.mustache

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ Drag an item to a destination element.
44
I.dragAndDrop('#dragHandle', '#container');
55
```
66

7-
@param {string|object} srcElement located by CSS|XPath|strict locator.
8-
@param {string|object} destElement located by CSS|XPath|strict locator.
7+
@param {LocatorOrString} srcElement located by CSS|XPath|strict locator.
8+
@param {LocatorOrString} destElement located by CSS|XPath|strict locator.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Get all Window Handles.
2+
Useful for referencing a specific handle when calling `I.switchToWindow(handle)`
3+
4+
```js
5+
const windows = await I.grabAllWindowHandles();
6+
```
7+
@returns {Promise<string[]>}

docs/webapi/grabBrowserLogs.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ let logs = await I.grabBrowserLogs();
66
console.log(JSON.stringify(logs))
77
```
88

9-
@returns {Promise<Array<*>>} all browser logs
9+
@returns {Promise<object[]>|undefined} all browser logs

docs/webapi/grabCookie.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ assert(cookie.value, '123456');
88
```
99

1010
@param {?string} [name=null] cookie name.
11-
@returns {Promise<string>} attribute value
11+
@returns {Promise<string>|Promise<string[]>} attribute value
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Get the current Window Handle.
2+
Useful for referencing it when calling `I.switchToWindow(handle)`
3+
```js
4+
const window = await I.grabCurrentWindowHandle();
5+
```
6+
@returns {Promise<string>}

docs/webapi/grabElementBoundingRect.mustache

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ To get only one metric use second parameter:
1515
const width = await I.grabElementBoundingRect('h3', 'width');
1616
// width == 527
1717
```
18-
@param {string|object} locator element located by CSS|XPath|strict locator.
19-
@param {string} elementSize x, y, width or height of the given element.
20-
@returns {object} Element bounding rectangle
18+
@param {LocatorOrString} locator element located by CSS|XPath|strict locator.
19+
@param {string=} elementSize x, y, width or height of the given element.
20+
@returns {Promise<DOMRect>|Promise<number>} Element bounding rectangle

docs/webapi/grabNumberOfOpenTabs.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Resumes test execution, so **should be used inside async function with `await`**
55
let tabs = await I.grabNumberOfOpenTabs();
66
```
77

8-
@returns {Promise<number>} number of open tabs
8+
@returns {Promise<number>} number of open tabs

docs/webapi/grabPageScrollPosition.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Resumes test execution, so **should be used inside an async function with `await
55
let { x, y } = await I.grabPageScrollPosition();
66
```
77

8-
@returns {Promise<Object<string, *>>} scroll position
8+
@returns {Promise<PageScrollPosition>} scroll position

docs/webapi/grabPopupText.mustache

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Grab the text within the popup. If no popup is visible then it will return null.
2+
```js
3+
await I.grabPopupText();
4+
```
5+
@returns {Promise<string>}

docs/webapi/openNewTab.mustache

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Open new tab and switch to it.
2+
3+
```js
4+
I.openNewTab();
5+
```

docs/webapi/scrollIntoView.mustache

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ I.scrollIntoView('#submit', true);
66
I.scrollIntoView('#submit', { behavior: "smooth", block: "center", inline: "center" });
77
```
88

9-
@param {string|object} locator located by CSS|XPath|strict locator.
10-
@param {boolean|object} alignToTop (optional) or scrollIntoViewOptions (optional), see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView.
9+
@param {LocatorOrString} locator located by CSS|XPath|strict locator.
10+
@param {ScrollIntoViewOptions} scrollIntoViewOptions see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView.

docs/webapi/seeTitleEquals.mustache

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Checks that title is equal to provided one.
2+
3+
```js
4+
I.seeTitleEquals('Test title.');
5+
```
6+
7+
@param {string} text value to check.

docs/webapi/selectOption.mustache

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ Provide an array for the second argument to select multiple options.
1616
```js
1717
I.selectOption('Which OS do you use?', ['Android', 'iOS']);
1818
```
19-
@param {CodeceptJS.LocatorOrString} select field located by label|name|CSS|XPath|strict locator.
20-
@param {string|Array<*>} option visible text or value of option.
19+
@param {LocatorOrString} select field located by label|name|CSS|XPath|strict locator.
20+
@param {string|Array<*>} option visible text or value of option.

docs/webapi/setCookie.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ I.setCookie([
1212
]);
1313
```
1414

15-
@param {object|array} cookie a cookie object or array of cookie objects.
15+
@param {Cookie|Array<Cookie>} cookie a cookie object or array of cookie objects.

docs/webapi/setGeoLocation.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ I.setGeoLocation(121.21, 11.56, 10);
88

99
@param {number} latitude to set.
1010
@param {number} longitude to set
11-
@param {number} altitude (optional, null by default) to set
11+
@param {number=} altitude (optional, null by default) to set

docs/webapi/switchToNextTab.mustache

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Switch focus to a particular tab by its number. It waits tabs loading and then switch tab.
2+
3+
```js
4+
I.switchToNextTab();
5+
I.switchToNextTab(2);
6+
```
7+
8+
@param {number} [num] (optional) number of tabs to switch forward, default: 1.
9+
@param {number | null} [sec] (optional) time in seconds to wait.
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Switch focus to a particular tab by its number. It waits tabs loading and then switch tab.
2+
3+
```js
4+
I.switchToPreviousTab();
5+
I.switchToPreviousTab(2);
6+
```
7+
8+
@param {number} [num] (optional) number of tabs to switch backward, default: 1.
9+
@param {number?} [sec] (optional) time in seconds to wait.

docs/webapi/waitForValue.mustache

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Waits for the specified value to be in value attribute.
44
I.waitForValue('//input', "GoodValue");
55
```
66

7-
@param {string|object} field input field.
7+
@param {LocatorOrString} field input field.
88
@param {string }value expected value.
9-
@param {number} [sec=1] (optional, `1` by default) time in seconds to wait
9+
@param {number} [sec=1] (optional, `1` by default) time in seconds to wait

lib/command/definitions.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ module.exports = function (genPath, options) {
4848
helperPaths[name] = require;
4949
helperNames.push(name);
5050
} else {
51-
helperNames.push(`CodeceptJS.${name}`);
51+
helperNames.push(name);
5252
}
5353
}
5454

5555
const supportObject = new Map();
56-
supportObject.set('I', 'CodeceptJS.I');
56+
supportObject.set('I', 'I');
5757
for (const name in codecept.config.include) {
5858
const includePath = codecept.config.include[name];
5959
if (name === 'I' || name === translations.I) {

0 commit comments

Comments
 (0)