From 0d7cd130508f77a58cfb0753bedb3effbbe6a5fa Mon Sep 17 00:00:00 2001 From: KobeN <7845001+kobenguyent@users.noreply.github.com> Date: Fri, 1 Mar 2024 18:07:27 +0100 Subject: [PATCH] fix: type check tests (#4227) --- docs/helpers/Detox.md | 246 ++++++---- lib/helper/Expect.js | 2 +- package.json | 17 +- tsconfig.json | 3 +- typings/fixDefFiles.js | 33 ++ typings/index.d.ts | 1 + typings/tests/actor.types.ts | 5 +- typings/tests/global-variables.types.ts | 111 +++-- typings/tests/helper.types.ts | 74 +-- typings/tests/helpers/Appium.types.ts | 178 +++---- typings/tests/helpers/AppiumTs.types.ts | 180 +++---- typings/tests/helpers/Playwright.types.ts | 285 ++++++------ typings/tests/helpers/PlaywrightTs.types.ts | 277 +++++------ typings/tests/helpers/WebDriverIO.types.ts | 489 ++++++++++---------- 14 files changed, 1040 insertions(+), 861 deletions(-) create mode 100644 typings/fixDefFiles.js diff --git a/docs/helpers/Detox.md b/docs/helpers/Detox.md index e26f55166..759f1468a 100644 --- a/docs/helpers/Detox.md +++ b/docs/helpers/Detox.md @@ -17,15 +17,15 @@ This is a wrapper on top of [Detox][1] library, aimied to unify testing experien Detox provides a grey box testing for mobile applications, playing especially good for React Native apps. Detox plays quite differently from Appium. To establish detox testing you need to build a mobile application in a special way to inject Detox code. -This why **Detox is grey box testing** solution, so you need an access to application source code, and a way to build and execute it on emulator. +This why **Detox is grey box testing** solution, so you need access to application source code, and a way to build and execute it on emulator. Comparing to Appium, Detox runs faster and more stable but requires an additional setup for build. ### Setup -1. [Install and configure Detox for iOS][2] and [Android][3] -2. [Build an application][4] using `detox build` command. -3. Install [CodeceptJS][5] and detox-helper: +1. [Install and configure Detox][2] +2. [Build an application][3] using `detox build` command. +3. Install [CodeceptJS][4] and detox-helper: npm i @codeceptjs/detox-helper --save @@ -36,15 +36,28 @@ If you completed step 1 and step 2 you should have a configuration similar this: ```js "detox": { - "configurations": { - "ios.sim.debug": { - "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/example.app", - "build": "xcodebuild -project ios/example.xcodeproj -scheme example -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build", - "type": "ios.simulator", - "name": "iPhone 7" - } - } - } + "configurations": { + "ios.sim.debug": { + "device": "simulator", + "app": "ios.debug" + } + }, + "apps": { + "ios.debug": { + "type": "ios.app", + "binaryPath": "../test/ios/build/Build/Products/Debug-iphonesimulator/MyTestApp.app", + "build": "xcodebuild -workspace ../test/ios/MyTestApp.xcworkspace -scheme MyTestApp -configuration Debug -sdk iphonesimulator -derivedDataPath ../test/ios/build" + } + }, + "devices": { + "simulator": { + "type": "ios.simulator", + "device": { + "type": "iPhone 15" + } + } + } + } ``` ### Configuration @@ -57,8 +70,8 @@ In `codecept.conf.js` enable Detox helper: helpers: { Detox: { require: '@codeceptjs/detox-helper', - configuration: '', - } + configuration: '', + } } ``` @@ -86,8 +99,22 @@ I.appendField('name', 'davert'); #### Parameters -- `field` **([string][6] \| [object][7])** -- `value` **[string][6]** +- `field` **([string][5] \| [object][6])** +- `value` **[string][5]** + +### checkIfElementExists + +Checks if an element exists. + +```js +I.checkIfElementExists('~edit'); // located by accessibility id +I.checkIfElementExists('~edit', '#menu'); // element inside #menu +``` + +#### Parameters + +- `locator` **([string][5] \| [object][6])** element to locate +- `context` **([string][5] \| [object][6] | null)** context element (optional, default `null`) ### clearField @@ -100,16 +127,16 @@ I.clearField('~name'); #### Parameters -- `field` **([string][6] \| [object][7])** an input element to clear +- `field` **([string][5] \| [object][6])** an input element to clear ### click -Clicks on an element. +Clicks on an element. Element can be located by its text or id or accessibility id The second parameter is a context (id | type | accessibility id) to narrow the search. -Same as [tap][8] +Same as [tap][7] ```js I.click('Login'); // locate by text @@ -121,8 +148,8 @@ I.click({ ios: 'Save', android: 'SAVE' }, '#main'); // different texts on iOS an #### Parameters -- `locator` **([string][6] \| [object][7])** -- `context` **([string][6] \| [object][7] | null)** (optional, default `null`) +- `locator` **([string][5] \| [object][6])** +- `context` **([string][5] \| [object][6] | null)** (optional, default `null`) ### clickAtPoint @@ -136,9 +163,9 @@ I.clickAtPoint('~save', 10, 10); // locate by accessibility id #### Parameters -- `locator` **([string][6] \| [object][7])** -- `x` **[number][9]** horizontal offset (optional, default `0`) -- `y` **[number][9]** vertical offset (optional, default `0`) +- `locator` **([string][5] \| [object][6])** +- `x` **[number][8]** horizontal offset (optional, default `0`) +- `y` **[number][8]** vertical offset (optional, default `0`) ### dontSee @@ -153,8 +180,8 @@ I.dontSee('Record deleted', '~message'); #### Parameters -- `text` **[string][6]** to check invisibility -- `context` **([string][6] \| [object][7] | null)** element in which to search for text (optional, default `null`) +- `text` **[string][5]** to check invisibility +- `context` **([string][5] \| [object][6] | null)** element in which to search for text (optional, default `null`) ### dontSeeElement @@ -168,8 +195,8 @@ I.dontSeeElement('~edit', '#menu'); // element inside #menu #### Parameters -- `locator` **([string][6] \| [object][7])** element to locate -- `context` **([string][6] \| [object][7] | null)** context element (optional, default `null`) +- `locator` **([string][5] \| [object][6])** element to locate +- `context` **([string][5] \| [object][6] | null)** context element (optional, default `null`) ### dontSeeElementExists @@ -183,8 +210,8 @@ I.dontSeeElementExist('~edit', '#menu'); // element inside #menu #### Parameters -- `locator` **([string][6] \| [object][7])** element to locate -- `context` **([string][6] \| [object][7])** context element (optional, default `null`) +- `locator` **([string][5] \| [object][6])** element to locate +- `context` **([string][5] \| [object][6])** context element (optional, default `null`) ### fillField @@ -199,8 +226,8 @@ I.fillField({ android: 'NAME', ios: 'name' }, 'davert'); #### Parameters -- `field` **([string][6] \| [object][7])** an input element to fill in -- `value` **[string][6]** value to fill +- `field` **([string][5] \| [object][6])** an input element to fill in +- `value` **[string][5]** value to fill ### goBack @@ -210,6 +237,14 @@ Goes back on Android I.goBack(); // on Android only ``` +### grabPlatform + +Grab the device platform + +```js +const platform = await I.grabPlatform(); +``` + ### installApp Installs a configured application. @@ -221,7 +256,7 @@ I.installApp(); ### launchApp -Launches an application. If application instance already exists, use [relaunchApp][10]. +Launches an application. If application instance already exists, use [relaunchApp][9]. ```js I.launchApp(); @@ -239,9 +274,9 @@ I.longPress('Update', 2, '#menu'); // locate by text inside #menu, hold for 2 se #### Parameters -- `locator` **([string][6] \| [object][7])** element to locate -- `sec` **[number][9]** number of seconds to hold tap -- `context` **([string][6] \| [object][7] | null)** context element (optional, default `null`) +- `locator` **([string][5] \| [object][6])** element to locate +- `sec` **[number][8]** number of seconds to hold tap +- `context` **([string][5] \| [object][6] | null)** context element (optional, default `null`) ### multiTap @@ -260,9 +295,9 @@ I.multiTap('Update', 2, '#menu'); // locate by id #### Parameters -- `locator` **([string][6] \| [object][7])** element to locate -- `num` **[number][9]** number of taps -- `context` **([string][6] \| [object][7] | null)** context element (optional, default `null`) +- `locator` **([string][5] \| [object][6])** element to locate +- `num` **[number][8]** number of taps +- `context` **([string][5] \| [object][6] | null)** context element (optional, default `null`) ### relaunchApp @@ -285,7 +320,7 @@ I.runOnAndroid(() => { #### Parameters -- `fn` **[Function][11]** a function which will be executed on android +- `fn` **[Function][10]** a function which will be executed on android ### runOnIOS @@ -300,7 +335,7 @@ I.runOnIOS(() => { #### Parameters -- `fn` **[Function][11]** a function which will be executed on iOS +- `fn` **[Function][10]** a function which will be executed on iOS ### saveScreenshot @@ -312,7 +347,7 @@ I.saveScreenshot('main-window.png'); #### Parameters -- `name` **[string][6]** +- `name` **[string][5]** ### scrollDown @@ -324,7 +359,7 @@ I.scrollDown('#container'); #### Parameters -- `locator` **([string][6] \| [object][7])** +- `locator` **([string][5] \| [object][6])** ### scrollLeft @@ -336,7 +371,7 @@ I.scrollLeft('#container'); #### Parameters -- `locator` **([string][6] \| [object][7])** +- `locator` **([string][5] \| [object][6])** ### scrollRight @@ -348,7 +383,18 @@ I.scrollRight('#container'); #### Parameters -- `locator` **([string][6] \| [object][7])** +- `locator` **([string][5] \| [object][6])** + +### scrollToElement + +Scrolls within a scrollable container to an element. + +#### Parameters + +- `targetLocator` **([string][5] \| [object][6])** Locator of the element to scroll to +- `containerLocator` **([string][5] \| [object][6])** Locator of the scrollable container +- `direction` **[string][5]** 'up' or 'down' (optional, default `'down'`) +- `offset` **[number][8]** Offset for scroll, can be adjusted based on need (optional, default `100`) ### scrollUp @@ -360,7 +406,7 @@ I.scrollUp('#container'); #### Parameters -- `locator` **([string][6] \| [object][7])** +- `locator` **([string][5] \| [object][6])** ### see @@ -375,8 +421,8 @@ I.see('Record deleted', '~message'); #### Parameters -- `text` **[string][6]** to check visibility -- `context` **([string][6] \| [object][7] | null)** element inside which to search for text (optional, default `null`) +- `text` **[string][5]** to check visibility +- `context` **([string][5] \| [object][6] | null)** element inside which to search for text (optional, default `null`) ### seeElement @@ -390,8 +436,8 @@ I.seeElement('~edit', '#menu'); // element inside #menu #### Parameters -- `locator` **([string][6] \| [object][7])** element to locate -- `context` **([string][6] \| [object][7] | null)** context element (optional, default `null`) +- `locator` **([string][5] \| [object][6])** element to locate +- `context` **([string][5] \| [object][6] | null)** context element (optional, default `null`) ### seeElementExists @@ -405,8 +451,8 @@ I.seeElementExists('~edit', '#menu'); // element inside #menu #### Parameters -- `locator` **([string][6] \| [object][7])** element to locate -- `context` **([string][6] \| [object][7])** context element (optional, default `null`) +- `locator` **([string][5] \| [object][6])** element to locate +- `context` **([string][5] \| [object][6])** context element (optional, default `null`) ### setLandscapeOrientation @@ -443,8 +489,8 @@ I.swipeUp('#container'); #### Parameters -- `locator` **([string][6] \| [object][7])** an element on which to perform swipe -- `speed` **[string][6]** a speed to perform: `slow` or `fast`. (optional, default `'slow'`) +- `locator` **([string][5] \| [object][6])** an element on which to perform swipe +- `speed` **[string][5]** a speed to perform: `slow` or `fast`. (optional, default `'slow'`) ### swipeLeft @@ -457,8 +503,8 @@ I.swipeUp('#container'); #### Parameters -- `locator` **([string][6] \| [object][7])** an element on which to perform swipe -- `speed` **[string][6]** a speed to perform: `slow` or `fast`. (optional, default `'slow'`) +- `locator` **([string][5] \| [object][6])** an element on which to perform swipe +- `speed` **[string][5]** a speed to perform: `slow` or `fast`. (optional, default `'slow'`) ### swipeRight @@ -471,8 +517,8 @@ I.swipeUp('#container'); #### Parameters -- `locator` **([string][6] \| [object][7])** an element on which to perform swipe -- `speed` **[string][6]** a speed to perform: `slow` or `fast`. (optional, default `'slow'`) +- `locator` **([string][5] \| [object][6])** an element on which to perform swipe +- `speed` **[string][5]** a speed to perform: `slow` or `fast`. (optional, default `'slow'`) ### swipeUp @@ -485,17 +531,17 @@ I.swipeUp('#container'); #### Parameters -- `locator` **([string][6] \| [object][7])** an element on which to perform swipe -- `speed` **[string][6]** a speed to perform: `slow` or `fast`. (optional, default `'slow'`) +- `locator` **([string][5] \| [object][6])** an element on which to perform swipe +- `speed` **[string][5]** a speed to perform: `slow` or `fast`. (optional, default `'slow'`) ### tap -Taps on an element. +Taps on an element. Element can be located by its text or id or accessibility id. The second parameter is a context element to narrow the search. -Same as [click][12] +Same as [click][11] ```js I.tap('Login'); // locate by text @@ -507,8 +553,40 @@ I.tap({ ios: 'Save', android: 'SAVE' }, '#main'); // different texts on iOS and #### Parameters -- `locator` **([string][6] \| [object][7])** -- `context` **([string][6] \| [object][7] | null)** (optional, default `null`) +- `locator` **([string][5] \| [object][6])** +- `context` **([string][5] \| [object][6] | null)** (optional, default `null`) + +### tapByLabel + +Clicks on an element. +Element can be located by its label + +The second parameter is a context (id | type | accessibility id) to narrow the search. + +```js +I.tapByLabel('Login'); // locate by text +I.tapByLabel('Login', '#nav'); // locate by text inside #nav +``` + +#### Parameters + +- `locator` **([string][5] \| [object][6])** +- `context` **([string][5] \| [object][6] | null)** (optional, default `null`) + +### tapReturnKey + +Taps return key. +A field can be located by text, accessibility id, id. + +```js +I.tapReturnKey('Username'); +I.tapReturnKey('~name'); +I.tapReturnKey({ android: 'NAME', ios: 'name' }); +``` + +#### Parameters + +- `field` **([string][5] \| [object][6])** an input element to fill in ### wait @@ -520,7 +598,7 @@ I.wait(2); // waits for 2 seconds #### Parameters -- `sec` **[number][9]** number of seconds to wait +- `sec` **[number][8]** number of seconds to wait ### waitForElement @@ -532,8 +610,8 @@ I.waitForElement('#message', 1); // wait for 1 second #### Parameters -- `locator` **([string][6] \| [object][7])** an element to wait for -- `sec` **[number][9]** number of seconds to wait, 5 by default (optional, default `5`) +- `locator` **([string][5] \| [object][6])** an element to wait for +- `sec` **[number][8]** number of seconds to wait, 5 by default (optional, default `5`) ### waitForElementVisible @@ -545,12 +623,12 @@ I.waitForElementVisible('#message', 1); // wait for 1 second #### Parameters -- `locator` **([string][6] \| [object][7])** an element to wait for -- `sec` **[number][9]** number of seconds to wait (optional, default `5`) +- `locator` **([string][5] \| [object][6])** an element to wait for +- `sec` **[number][8]** number of seconds to wait (optional, default `5`) ### waitToHide -Waits an elment to become not visible. +Waits an elmenet to become not visible. ```js I.waitToHide('#message', 2); // wait for 2 seconds @@ -558,29 +636,27 @@ I.waitToHide('#message', 2); // wait for 2 seconds #### Parameters -- `locator` **([string][6] \| [object][7])** an element to wait for -- `sec` **[number][9]** number of seconds to wait (optional, default `5`) +- `locator` **([string][5] \| [object][6])** an element to wait for +- `sec` **[number][8]** number of seconds to wait (optional, default `5`) [1]: https://github.com/wix/Detox -[2]: https://github.com/wix/Detox/blob/master/docs/Introduction.GettingStarted.md - -[3]: https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md +[2]: https://wix.github.io/Detox/docs/introduction/project-setup -[4]: https://github.com/wix/Detox/blob/master/docs/Introduction.GettingStarted.md#step-4-build-your-app-and-run-detox-tests +[3]: https://wix.github.io/Detox/docs/introduction/project-setup#step-5-build-the-app -[5]: https://codecept.io +[4]: https://codecept.io -[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[8]: #tap +[7]: #tap -[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[10]: #relaunchApp +[9]: #relaunchApp -[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function +[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function -[12]: #click +[11]: #click diff --git a/lib/helper/Expect.js b/lib/helper/Expect.js index f9cb3e3bf..c9de3693c 100644 --- a/lib/helper/Expect.js +++ b/lib/helper/Expect.js @@ -190,7 +190,7 @@ class ExpectHelper { * @param {*} targetData * @param {*} jsonSchema * @param {*} [customErrorMsg] - * @param {*} ajvOptions Pass AJV options + * @param {*} [ajvOptions] Pass AJV options */ expectJsonSchemaUsingAJV( targetData, diff --git a/package.json b/package.json index bf4eec7c2..2610cf1ac 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "docs/webapi/**" ], "main": "lib/index.js", - "typings": "typings/index.d.ts", + "types": "typings/index.d.ts", "bin": { "codeceptjs": "./bin/codecept.js" }, @@ -62,7 +62,8 @@ "dev:graphql": "node test/data/graphql/index.js", "publish:site": "./runok.js publish:site", "update-contributor-faces": "./runok.js contributor:faces", - "dtslint": "dtslint typings --localTs './node_modules/typescript/lib'", + "types-fix": "node typings/fixDefFiles.js", + "dtslint": "npm run types-fix && tsd", "prepare": "husky install", "prepare-release": "./runok.js versioning && ./runok.js get:commit-log" }, @@ -115,7 +116,7 @@ "uuid": "9.0" }, "optionalDependencies": { - "@codeceptjs/detox-helper": "1.0.2" + "@codeceptjs/detox-helper": "1.0.5" }, "devDependencies": { "@codeceptjs/mock-request": "0.3.1", @@ -134,7 +135,6 @@ "chai-subset": "1.6.0", "contributor-faces": "1.1.0", "documentation": "12.3.0", - "dtslint": "4.2.1", "electron": "28.2.1", "eslint": "8.56.0", "eslint-config-airbnb-base": "15.0.0", @@ -158,6 +158,7 @@ "testcafe": "3.5.0", "ts-morph": "21.0.1", "ts-node": "10.9.2", + "tsd": "^0.30.7", "tsd-jsdoc": "2.5.0", "typedoc": "0.25.7", "typedoc-plugin-markdown": "3.17.1", @@ -171,5 +172,11 @@ "node": ">=16.0", "npm": ">=5.6.0" }, - "es6": true + "es6": true, + "tsd": { + "directory": "typings", + "compilerOptions": { + "strict": false + } + } } diff --git a/tsconfig.json b/tsconfig.json index a3d4e5946..8c3ad592f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,8 @@ "noImplicitAny": false, "noImplicitThis": false, "noEmit": true, - "strictNullChecks": true + "strictNullChecks": true, + "moduleDetection": "force" }, "exclude": ["node_modules", "typings/tests"], "compileOnSave": true, diff --git a/typings/fixDefFiles.js b/typings/fixDefFiles.js new file mode 100644 index 000000000..f0e1e0d97 --- /dev/null +++ b/typings/fixDefFiles.js @@ -0,0 +1,33 @@ +const fs = require('fs'); +const { resolve } = require('path'); + +const filePath = [resolve('./typings/promiseBasedTypes.d.ts'), resolve('./typings/types.d.ts')]; + +filePath.forEach(file => { + fs.readFile(file, 'utf8', (err, data) => { + if (err) { + console.error(`Error reading the file: ${err}`); + return; + } + + const modifiedContent = modifyContent(data); + + // Write the modified content back to the file + fs.writeFile(file, modifiedContent, 'utf8', (err) => { + if (err) { + console.error(`Error writing to the file: ${err}`); + return; + } + + console.log(`${file} file is successfully modified and saved.`); + }); + }); +}); + +function modifyContent(content) { + const modifiedContent = content.replace(/ class MockServer {/g, ' // @ts-ignore\n' + + ' class MockServer {').replace(/ type MockServerConfig = {/g, ' // @ts-ignore\n' + + ' type MockServerConfig = {').replace(/ class ExpectHelper {/g, ' // @ts-ignore\n' + + ' class ExpectHelper {'); + return modifiedContent; +} diff --git a/typings/index.d.ts b/typings/index.d.ts index 6c8e32711..c13bc1d98 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -8,6 +8,7 @@ declare namespace CodeceptJS { type WithTranslation = T & + // @ts-ignore import("./utils").Translate; type Cookie = { diff --git a/typings/tests/actor.types.ts b/typings/tests/actor.types.ts index a8bec8d00..8ab9e9fe0 100644 --- a/typings/tests/actor.types.ts +++ b/typings/tests/actor.types.ts @@ -1,6 +1,9 @@ +import { expectError } from 'tsd'; + +// @ts-ignore const I = actor(); I.retry(); I.retry(1); I.retry({ retries: 3, minTimeout: 100 }); -I.retry(1, 2); // $ExpectError +expectError(I.retry(1, 2)); diff --git a/typings/tests/global-variables.types.ts b/typings/tests/global-variables.types.ts index bde0d9017..aa21f2cca 100644 --- a/typings/tests/global-variables.types.ts +++ b/typings/tests/global-variables.types.ts @@ -1,54 +1,85 @@ -Feature() // $ExpectError -Scenario() // $ExpectError -Before() // $ExpectError -BeforeSuite() // $ExpectError -After() // $ExpectError -AfterSuite() // $ExpectError +import { expectError, expectType } from 'tsd'; -Feature('feature') // $ExpectType FeatureConfig -Scenario('scenario') // $ExpectType ScenarioConfig -Scenario( +expectError(Feature()); +expectError(Scenario()); +expectError(Before()); +expectError(BeforeSuite()); +expectError(After()); +expectError(AfterSuite()); + +// @ts-ignore +expectType(Feature('feature')) + +// @ts-ignore +expectType(Scenario('scenario')) + +// @ts-ignore +expectType(Scenario( 'scenario', {}, // $ExpectType {} () => {} // $ExpectType () => void -) -Scenario( +)) + +// @ts-ignore +expectType(Scenario( 'scenario', () => {} // $ExpectType () => void -) +)) + +// @ts-ignore const callback: CodeceptJS.HookCallback = () => {} -Scenario( + +// @ts-ignore +expectType(Scenario( 'scenario', callback // $ExpectType HookCallback -) -Scenario('scenario', +)) + +// @ts-ignore +expectType(Scenario('scenario', (args) => { - args // $ExpectType SupportObject - args.I // $ExpectType I + // @ts-ignore + expectType(args) + // @ts-ignore + expectType(args.I) // $ExpectType I } -) -Scenario( +)) + +// @ts-ignore +expectType(Scenario( 'scenario', async () => {} // $ExpectType () => Promise -) - -Before((args) => { - args // $ExpectType SupportObject - args.I // $ExpectType I -}) - -BeforeSuite((args) => { - args // $ExpectType SupportObject - args.I // $ExpectType I -}) - -After((args) => { - args // $ExpectType SupportObject - args.I // $ExpectType I -}) - -AfterSuite((args) => { - args // $ExpectType SupportObject - args.I // $ExpectType I -}) +)) + +// @ts-ignore +expectType(Before((args) => { + // @ts-ignore + expectType(args) + // @ts-ignore + expectType(args.I) +})) + +// @ts-ignore +expectType(BeforeSuite((args) => { + // @ts-ignore + expectType(args) + // @ts-ignore + expectType(args.I) +})) + +// @ts-ignore +expectType(After((args) => { + // @ts-ignore + expectType(args) + // @ts-ignore + expectType(args.I) +})) + +// @ts-ignore +expectType(AfterSuite((args) => { + // @ts-ignore + expectType(args) + // @ts-ignore + expectType(args.I) +})) diff --git a/typings/tests/helper.types.ts b/typings/tests/helper.types.ts index 1f02ecea7..432aaf0e3 100644 --- a/typings/tests/helper.types.ts +++ b/typings/tests/helper.types.ts @@ -1,46 +1,52 @@ // @TODO: Need tests arguments of protected methods +import Helper from '@codeceptjs/helper' +import { expectError, expectType } from 'tsd'; + class CustomClass extends Helper { constructor(config: any) { super( - config // $ExpectType any + expectType(config) ) - this.helpers // $ExpectType any - this.debug() // $ExpectError - this.debugSection() // $ExpectError - this.debugSection('[Section]') // $ExpectError + // @ts-ignore + expectType(this.helpers) + expectError(this.debug()) + expectError(this.debugSection()) + expectError(this.debugSection('[Section]')) - this.debug('log') // $ExpectType void - this.debugSection('[Section]', 'log') // $ExpectType void + // @ts-ignore + expectType(this.debug('log')) + // @ts-ignore + expectType(this.debugSection('[Section]', 'log')) } - _failed() {} // $ExpectType () => void - _finishTest() {} // $ExpectType () => void - _init() {} // $ExpectType () => void - _passed() {} // $ExpectType () => void - _setConfig() {} // $ExpectType () => void - _useTo() {} // $ExpectType () => void - _validateConfig() {} // $ExpectType () => void - _before() {} // $ExpectType () => void - _beforeStep() {} // $ExpectType () => void - _beforeSuite() {} // $ExpectType () => void - _after() {} // $ExpectType () => void - _afterStep() {} // $ExpectType () => void - _afterSuite() {} // $ExpectType () => void + _failed() {} + _finishTest() {} + _init() {} + _passed() {} + _setConfig() {} + _useTo() {} + _validateConfig() {} + _before() {} + _beforeStep() {} + _beforeSuite() {} + _after() {} + _afterStep() {} + _afterSuite() {} } -const customClass = new Helper({}) +const customClass = new CustomClass({}) -customClass._failed() // $ExpectError -customClass._finishTest() // $ExpectError -customClass._init() // $ExpectError -customClass._passed() // $ExpectError -customClass._setConfig() // $ExpectError -customClass._validateConfig() // $ExpectError -customClass._before() // $ExpectError -customClass._beforeStep() // $ExpectError -customClass._beforeSuite() // $ExpectError -customClass._after() // $ExpectError -customClass._afterStep() // $ExpectError -customClass._afterSuite() // $ExpectError +expectType(customClass._failed()) +expectType(customClass._finishTest()) +expectType(customClass._init()) +expectType(customClass._passed()) +expectType(customClass._setConfig()) +expectType(customClass._validateConfig()) +expectType(customClass._before()) +expectType(customClass._beforeStep()) +expectType(customClass._beforeSuite()) +expectType(customClass._after()) +expectType(customClass._afterStep()) +expectType(customClass._afterSuite()) -customClass._useTo() // $ExpectType void +expectType(customClass._useTo()) diff --git a/typings/tests/helpers/Appium.types.ts b/typings/tests/helpers/Appium.types.ts index 1187e0d01..458519b16 100644 --- a/typings/tests/helpers/Appium.types.ts +++ b/typings/tests/helpers/Appium.types.ts @@ -1,96 +1,98 @@ -export {}; // mark the file as external module to redeclare variables in the same block +import { expectError, expectType } from 'tsd'; +// @ts-ignore const appium = new CodeceptJS.Appium(); -const str = "text"; +const str = 'text'; const num = 1; -const appPackage = "com.example.android.apis"; +const appPackage = 'com.example.android.apis'; -appium.touchPerform(); // $ExpectError -appium.touchPerform("press"); // $ExpectError -appium.touchPerform([{ action: "press" }]); // $ExpectType void -appium.touchPerform([{ action: "press" }, { action: "release" }]); // $ExpectType void -appium.touchPerform([{ action: "press" }], [{ action: "release" }]); // $ExpectError +expectError(appium.touchPerform()); +expectError(appium.touchPerform('press')); +expectType(appium.touchPerform([{ action: 'press' }])); +expectType(appium.touchPerform([{ action: 'press' }, { action: 'release' }])); +expectError(appium.touchPerform([{ action: 'press' }], [{ action: 'release' }])); -appium.hideDeviceKeyboard(); // $ExpectType void -appium.hideDeviceKeyboard("tapOutside"); // $ExpectType void -appium.hideDeviceKeyboard("pressKey", "Done"); // $ExpectType void -appium.hideDeviceKeyboard("pressKey", "Done", "Done"); // $ExpectError +expectType(appium.hideDeviceKeyboard()); +expectType(appium.hideDeviceKeyboard('tapOutside')); +expectType(appium.hideDeviceKeyboard('pressKey', 'Done')); +expectError(appium.hideDeviceKeyboard('pressKey', 'Done', 'Done')); -appium.removeApp(); // $ExpectError -appium.removeApp("appName"); // $ExpectType void -appium.removeApp("appName", appPackage); // $ExpectType void -appium.removeApp("appName", appPackage, "remove"); // $ExpectError +expectError(appium.removeApp()); +expectType(appium.removeApp('appName')); +expectType(appium.removeApp('appName', appPackage)); +expectError(appium.removeApp('appName', appPackage, 'remove')); + +expectType(appium.runOnIOS(str, () => {})); +expectType(appium.runOnAndroid(str, () => {})); +expectType>(appium.seeAppIsInstalled(str)); +expectType>(appium.seeAppIsNotInstalled(str)); +expectType>(appium.installApp(str)); +expectType(appium.removeApp(str)); +expectType>(appium.seeCurrentActivityIs(str)); +expectType>(appium.seeDeviceIsLocked()); +expectType>(appium.seeDeviceIsUnlocked()); +expectType>(appium.seeOrientationIs('LANDSCAPE')); +expectType(appium.setOrientation('LANDSCAPE')); +expectType>(appium.grabAllContexts()); +expectType>(appium.grabContext()); +expectType>(appium.grabCurrentActivity()); +expectType>(appium.grabNetworkConnection()); +expectType>(appium.grabOrientation()); +expectType>(appium.grabSettings()); +expectType(appium.switchToContext(str)); +expectType>(appium.switchToWeb()); +expectType>(appium.switchToNative()); +expectType>(appium.switchToNative(str)); +expectError(appium.startActivity()); +expectError(appium.startActivity(appPackage)); +expectType>(appium.startActivity(appPackage, '.RegisterUserActivity')); +expectType>(appium.setNetworkConnection(num)); +expectError(appium.setNetworkConnection()); +expectType(appium.setSettings(str)); +expectType(appium.hideDeviceKeyboard()); +expectType>(appium.sendDeviceKeyEvent(num)); +expectType>(appium.openNotifications()); +expectType>(appium.makeTouchAction()); +expectType>(appium.tap(str)); +expectType(appium.performSwipe(str, str)); +expectType>(appium.swipeDown(str)); +expectType>(appium.swipeLeft(str)); +expectType>(appium.swipeRight(str)); +expectType>(appium.swipeUp(str)); +expectType>(appium.swipeTo(str, str, str, num, num, num)); +expectType(appium.touchPerform([])); +expectType>(appium.pullFile(str, str)); +expectType>(appium.shakeDevice()); +expectType>(appium.rotate()); +expectType>(appium.setImmediateValue()); +expectType>(appium.simulateTouchId()); +expectType>(appium.closeApp()); +expectType(appium.appendField(str, str)); +expectType(appium.checkOption(str)); +expectType(appium.click(str)); +expectType(appium.dontSeeCheckboxIsChecked(str)); +expectType(appium.dontSeeElement(str)); +expectType(appium.dontSeeInField(str, str)); +expectType(appium.dontSee(str)); +expectType(appium.fillField(str, str)); +expectType>(appium.grabTextFromAll(str)); +expectType>(appium.grabTextFrom(str)); +expectType>(appium.grabNumberOfVisibleElements(str)); +expectType>(appium.grabAttributeFrom(str, str)); +expectType>(appium.grabAttributeFromAll(str, str)); +expectType>(appium.grabValueFromAll(str)); +expectType>(appium.grabValueFrom(str)); +expectType>(appium.saveScreenshot(str)); +expectType(appium.scrollIntoView(str, {})); +expectType(appium.scrollIntoView(str, true)); +expectType(appium.seeCheckboxIsChecked(str)); +expectType(appium.seeElement(str)); +expectType(appium.seeInField(str, str)); +expectType(appium.see(str)); +expectType(appium.selectOption(str, str)); +expectType(appium.waitForElement(str)); +expectType(appium.waitForVisible(str)); +expectType(appium.waitForInvisible(str)); +expectType(appium.waitForText(str)); -appium.runOnIOS(str, () => {}); // $ExpectType void -appium.runOnAndroid(str, () => {}); // $ExpectType void -appium.seeAppIsInstalled(str); // $ExpectType Promise -appium.seeAppIsNotInstalled(str); // $ExpectType Promise -appium.installApp(str); // $ExpectType Promise -appium.removeApp(str); // $ExpectType void -appium.seeCurrentActivityIs(str); // $ExpectType Promise -appium.seeDeviceIsLocked(); // $ExpectType Promise -appium.seeDeviceIsUnlocked(); // $ExpectType Promise -appium.seeOrientationIs("LANDSCAPE"); // $ExpectType Promise -appium.setOrientation("LANDSCAPE"); // $ExpectType void -appium.grabAllContexts(); // $ExpectType Promise -appium.grabContext(); // $ExpectType Promise -appium.grabCurrentActivity(); // $ExpectType Promise -appium.grabNetworkConnection(); // $ExpectType Promise<{}> -appium.grabOrientation(); // $ExpectType Promise -appium.grabSettings(); // $ExpectType Promise -appium.switchToContext(str); // $ExpectType void -appium.switchToWeb(); // $ExpectType Promise -appium.switchToNative(); // $ExpectType Promise -appium.switchToNative(str); // $ExpectType Promise -appium.startActivity(); // $ExpectError -appium.startActivity(appPackage); // $ExpectError -appium.startActivity(appPackage, '.RegisterUserActivity'); // $ExpectType Promise -appium.setNetworkConnection(num); // $ExpectType Promise -appium.setNetworkConnection(); // $ExpectError -appium.setSettings(str); // $ExpectType void -appium.hideDeviceKeyboard(); // $ExpectType void -appium.sendDeviceKeyEvent(num); // $ExpectType Promise -appium.openNotifications(); // $ExpectType Promise -appium.makeTouchAction(); // $ExpectType Promise -appium.tap(str); // $ExpectType Promise -appium.performSwipe(str, str); // $ExpectType void -appium.swipeDown(str); // $ExpectType Promise -appium.swipeLeft(str); // $ExpectType Promise -appium.swipeRight(str); // $ExpectType Promise -appium.swipeUp(str); // $ExpectType Promise -appium.swipeTo(str, str, str, num, num, num); // $ExpectType Promise -appium.touchPerform([]); // $ExpectType void -appium.pullFile(str, str); // $ExpectType Promise -appium.shakeDevice(); // $ExpectType Promise -appium.rotate(); // $ExpectType Promise -appium.setImmediateValue(); // $ExpectType Promise -appium.simulateTouchId(); // $ExpectType Promise -appium.closeApp(); // $ExpectType Promise -appium.appendField(str, str); // $ExpectType void -appium.checkOption(str); // $ExpectType void -appium.click(str); // $ExpectType void -appium.dontSeeCheckboxIsChecked(str); // $ExpectType void -appium.dontSeeElement(str); // $ExpectType void -appium.dontSeeInField(str, str); // $ExpectType void -appium.dontSee(str); // $ExpectType void -appium.fillField(str, str); // $ExpectType void -appium.grabTextFromAll(str); // $ExpectType Promise -appium.grabTextFrom(str); // $ExpectType Promise -appium.grabNumberOfVisibleElements(str); // $ExpectType Promise -appium.grabAttributeFrom(str, str); // $ExpectType Promise -appium.grabAttributeFromAll(str, str); // $ExpectType Promise -appium.grabValueFromAll(str); // $ExpectType Promise -appium.grabValueFrom(str); // $ExpectType Promise -appium.saveScreenshot(str); // $ExpectType Promise -appium.scrollIntoView(str, {}); // $ExpectType void -appium.scrollIntoView(str, true); // $ExpectType void -appium.seeCheckboxIsChecked(str); // $ExpectType void -appium.seeElement(str); // $ExpectType void -appium.seeInField(str, str); // $ExpectType void -appium.see(str); // $ExpectType void -appium.selectOption(str, str); // $ExpectType void -appium.waitForElement(str); // $ExpectType void -appium.waitForVisible(str); // $ExpectType void -appium.waitForInvisible(str); // $ExpectType void -appium.waitForText(str); // $ExpectType void diff --git a/typings/tests/helpers/AppiumTs.types.ts b/typings/tests/helpers/AppiumTs.types.ts index a4a758ad8..458519b16 100644 --- a/typings/tests/helpers/AppiumTs.types.ts +++ b/typings/tests/helpers/AppiumTs.types.ts @@ -1,96 +1,98 @@ -export {}; // mark the file as external module to redeclare variables in the same block +import { expectError, expectType } from 'tsd'; -const appium = new CodeceptJS.AppiumTs(); +// @ts-ignore +const appium = new CodeceptJS.Appium(); -const str = "text"; +const str = 'text'; const num = 1; -const appPackage = "com.example.android.apis"; +const appPackage = 'com.example.android.apis'; -appium.touchPerform(); // $ExpectError -appium.touchPerform("press"); // $ExpectError -appium.touchPerform([{ action: "press" }]); // $ExpectType Promise -appium.touchPerform([{ action: "press" }, { action: "release" }]); // $ExpectType Promise -appium.touchPerform([{ action: "press" }], [{ action: "release" }]); // $ExpectError +expectError(appium.touchPerform()); +expectError(appium.touchPerform('press')); +expectType(appium.touchPerform([{ action: 'press' }])); +expectType(appium.touchPerform([{ action: 'press' }, { action: 'release' }])); +expectError(appium.touchPerform([{ action: 'press' }], [{ action: 'release' }])); -appium.hideDeviceKeyboard(); // $ExpectType Promise -appium.hideDeviceKeyboard("tapOutside"); // $ExpectType Promise -appium.hideDeviceKeyboard("pressKey", "Done"); // $ExpectType Promise -appium.hideDeviceKeyboard("pressKey", "Done", "Done"); // $ExpectError +expectType(appium.hideDeviceKeyboard()); +expectType(appium.hideDeviceKeyboard('tapOutside')); +expectType(appium.hideDeviceKeyboard('pressKey', 'Done')); +expectError(appium.hideDeviceKeyboard('pressKey', 'Done', 'Done')); -appium.removeApp(); // $ExpectError -appium.removeApp("appName"); // $ExpectType Promise -appium.removeApp("appName", appPackage); // $ExpectType Promise -appium.removeApp("appName", appPackage, "remove"); // $ExpectError +expectError(appium.removeApp()); +expectType(appium.removeApp('appName')); +expectType(appium.removeApp('appName', appPackage)); +expectError(appium.removeApp('appName', appPackage, 'remove')); + +expectType(appium.runOnIOS(str, () => {})); +expectType(appium.runOnAndroid(str, () => {})); +expectType>(appium.seeAppIsInstalled(str)); +expectType>(appium.seeAppIsNotInstalled(str)); +expectType>(appium.installApp(str)); +expectType(appium.removeApp(str)); +expectType>(appium.seeCurrentActivityIs(str)); +expectType>(appium.seeDeviceIsLocked()); +expectType>(appium.seeDeviceIsUnlocked()); +expectType>(appium.seeOrientationIs('LANDSCAPE')); +expectType(appium.setOrientation('LANDSCAPE')); +expectType>(appium.grabAllContexts()); +expectType>(appium.grabContext()); +expectType>(appium.grabCurrentActivity()); +expectType>(appium.grabNetworkConnection()); +expectType>(appium.grabOrientation()); +expectType>(appium.grabSettings()); +expectType(appium.switchToContext(str)); +expectType>(appium.switchToWeb()); +expectType>(appium.switchToNative()); +expectType>(appium.switchToNative(str)); +expectError(appium.startActivity()); +expectError(appium.startActivity(appPackage)); +expectType>(appium.startActivity(appPackage, '.RegisterUserActivity')); +expectType>(appium.setNetworkConnection(num)); +expectError(appium.setNetworkConnection()); +expectType(appium.setSettings(str)); +expectType(appium.hideDeviceKeyboard()); +expectType>(appium.sendDeviceKeyEvent(num)); +expectType>(appium.openNotifications()); +expectType>(appium.makeTouchAction()); +expectType>(appium.tap(str)); +expectType(appium.performSwipe(str, str)); +expectType>(appium.swipeDown(str)); +expectType>(appium.swipeLeft(str)); +expectType>(appium.swipeRight(str)); +expectType>(appium.swipeUp(str)); +expectType>(appium.swipeTo(str, str, str, num, num, num)); +expectType(appium.touchPerform([])); +expectType>(appium.pullFile(str, str)); +expectType>(appium.shakeDevice()); +expectType>(appium.rotate()); +expectType>(appium.setImmediateValue()); +expectType>(appium.simulateTouchId()); +expectType>(appium.closeApp()); +expectType(appium.appendField(str, str)); +expectType(appium.checkOption(str)); +expectType(appium.click(str)); +expectType(appium.dontSeeCheckboxIsChecked(str)); +expectType(appium.dontSeeElement(str)); +expectType(appium.dontSeeInField(str, str)); +expectType(appium.dontSee(str)); +expectType(appium.fillField(str, str)); +expectType>(appium.grabTextFromAll(str)); +expectType>(appium.grabTextFrom(str)); +expectType>(appium.grabNumberOfVisibleElements(str)); +expectType>(appium.grabAttributeFrom(str, str)); +expectType>(appium.grabAttributeFromAll(str, str)); +expectType>(appium.grabValueFromAll(str)); +expectType>(appium.grabValueFrom(str)); +expectType>(appium.saveScreenshot(str)); +expectType(appium.scrollIntoView(str, {})); +expectType(appium.scrollIntoView(str, true)); +expectType(appium.seeCheckboxIsChecked(str)); +expectType(appium.seeElement(str)); +expectType(appium.seeInField(str, str)); +expectType(appium.see(str)); +expectType(appium.selectOption(str, str)); +expectType(appium.waitForElement(str)); +expectType(appium.waitForVisible(str)); +expectType(appium.waitForInvisible(str)); +expectType(appium.waitForText(str)); -appium.runOnIOS(str, () => {}); // $ExpectType Promise -appium.runOnAndroid(str, () => {}); // $ExpectType Promise -appium.seeAppIsInstalled(str); // $ExpectType Promise -appium.seeAppIsNotInstalled(str); // $ExpectType Promise -appium.installApp(str); // $ExpectType Promise -appium.removeApp(str); // $ExpectType Promise -appium.seeCurrentActivityIs(str); // $ExpectType Promise -appium.seeDeviceIsLocked(); // $ExpectType Promise -appium.seeDeviceIsUnlocked(); // $ExpectType Promise -appium.seeOrientationIs("LANDSCAPE"); // $ExpectType Promise -appium.setOrientation("LANDSCAPE"); // $ExpectType Promise -appium.grabAllContexts(); // $ExpectType Promise -appium.grabContext(); // $ExpectType Promise -appium.grabCurrentActivity(); // $ExpectType Promise -appium.grabNetworkConnection(); // $ExpectType Promise<{}> -appium.grabOrientation(); // $ExpectType Promise -appium.grabSettings(); // $ExpectType Promise -appium.switchToContext(str); // $ExpectType Promise -appium.switchToWeb(); // $ExpectType Promise -appium.switchToNative(); // $ExpectType Promise -appium.switchToNative(str); // $ExpectType Promise -appium.startActivity(); // $ExpectError -appium.startActivity(appPackage); // $ExpectError -appium.startActivity(appPackage, '.RegisterUserActivity'); // $ExpectType Promise -appium.setNetworkConnection(num); // $ExpectType Promise -appium.setNetworkConnection(); // $ExpectError -appium.setSettings(str); // $ExpectType Promise -appium.hideDeviceKeyboard(); // $ExpectType Promise -appium.sendDeviceKeyEvent(num); // $ExpectType Promise -appium.openNotifications(); // $ExpectType Promise -appium.makeTouchAction(); // $ExpectType Promise -appium.tap(str); // $ExpectType Promise -appium.performSwipe(str, str); // $ExpectType Promise -appium.swipeDown(str); // $ExpectType Promise -appium.swipeLeft(str); // $ExpectType Promise -appium.swipeRight(str); // $ExpectType Promise -appium.swipeUp(str); // $ExpectType Promise -appium.swipeTo(str, str, str, num, num, num); // $ExpectType Promise -appium.touchPerform([]); // $ExpectType Promise -appium.pullFile(str, str); // $ExpectType Promise -appium.shakeDevice(); // $ExpectType Promise -appium.rotate(); // $ExpectType Promise -appium.setImmediateValue(); // $ExpectType Promise -appium.simulateTouchId(); // $ExpectType Promise -appium.closeApp(); // $ExpectType Promise -appium.appendField(str, str); // $ExpectType Promise -appium.checkOption(str); // $ExpectType Promise -appium.click(str); // $ExpectType Promise -appium.dontSeeCheckboxIsChecked(str); // $ExpectType Promise -appium.dontSeeElement(str); // $ExpectType Promise -appium.dontSeeInField(str, str); // $ExpectType Promise -appium.dontSee(str); // $ExpectType Promise -appium.fillField(str, str); // $ExpectType Promise -appium.grabTextFromAll(str); // $ExpectType Promise -appium.grabTextFrom(str); // $ExpectType Promise -appium.grabNumberOfVisibleElements(str); // $ExpectType Promise -appium.grabAttributeFrom(str, str); // $ExpectType Promise -appium.grabAttributeFromAll(str, str); // $ExpectType Promise -appium.grabValueFromAll(str); // $ExpectType Promise -appium.grabValueFrom(str); // $ExpectType Promise -appium.saveScreenshot(str); // $ExpectType Promise -appium.scrollIntoView(str, {}); // $ExpectType Promise -appium.scrollIntoView(str, true); // $ExpectType Promise -appium.seeCheckboxIsChecked(str); // $ExpectType Promise -appium.seeElement(str); // $ExpectType Promise -appium.seeInField(str, str); // $ExpectType Promise -appium.see(str); // $ExpectType Promise -appium.selectOption(str, str); // $ExpectType Promise -appium.waitForElement(str); // $ExpectType Promise -appium.waitForVisible(str); // $ExpectType Promise -appium.waitForInvisible(str); // $ExpectType Promise -appium.waitForText(str); // $ExpectType Promise diff --git a/typings/tests/helpers/Playwright.types.ts b/typings/tests/helpers/Playwright.types.ts index 3f8c7154d..151485bff 100644 --- a/typings/tests/helpers/Playwright.types.ts +++ b/typings/tests/helpers/Playwright.types.ts @@ -1,5 +1,6 @@ -export {}; // mark the file as external module to redeclare variables in the same block +import { expectError, expectType } from 'tsd'; +// @ts-ignore const playwright = new CodeceptJS.Playwright(); const str = 'text'; @@ -8,145 +9,145 @@ const position = { x: 100, y: 200 }; const sourcePosition = { x: 10, y: 20 }; const targetPosition = { x: 20, y: 30 }; -playwright.usePlaywrightTo(str, () => {}); // $ExpectType void -playwright.amAcceptingPopups(); // $ExpectType void -playwright.acceptPopup(); // $ExpectType void -playwright.amCancellingPopups(); // $ExpectType void -playwright.cancelPopup(); // $ExpectType void -playwright.seeInPopup(str); // $ExpectType void -playwright._setPage(str); // $ExpectType void -playwright._addPopupListener(); // $ExpectType void -playwright._getPageUrl(); // $ExpectType void -playwright.grabPopupText(); // $ExpectType Promise -playwright._createContextPage(); // $ExpectType void -playwright._createContextPage({}); // $ExpectType void -playwright.amOnPage(str); // $ExpectType void -playwright.resizeWindow(num, num); // $ExpectType void -playwright.setPlaywrightRequestHeaders(str); // $ExpectType void -playwright.moveCursorTo(str, num, num); // $ExpectType void -playwright.dragAndDrop(str); // $ExpectError -playwright.dragAndDrop(str, str); // $ExpectType void -playwright.dragAndDrop(str, str, { sourcePosition, targetPosition }); // $ExpectType void -playwright.restartBrowser(); // $ExpectType void -playwright.restartBrowser({}); // $ExpectType void -playwright.refreshPage(); // $ExpectType void -playwright.scrollPageToTop(); // $ExpectType void -playwright.scrollPageToBottom(); // $ExpectType void -playwright.scrollTo(str, num, num); // $ExpectType void -playwright.seeInTitle(str); // $ExpectType void -playwright.grabPageScrollPosition(); // $ExpectType Promise -playwright.seeTitleEquals(str); // $ExpectType void -playwright.dontSeeInTitle(str); // $ExpectType void -playwright.grabTitle(); // $ExpectType Promise -playwright._locate(); // $ExpectType void -playwright._locateCheckable(); // $ExpectType void -playwright._locateClickable(); // $ExpectType void -playwright._locateFields(); // $ExpectType void -playwright.switchToNextTab(); // $ExpectType void -playwright.switchToPreviousTab(); // $ExpectType void -playwright.closeCurrentTab(); // $ExpectType void -playwright.closeOtherTabs(); // $ExpectType void -playwright.openNewTab(); // $ExpectType void -playwright.grabNumberOfOpenTabs(); // $ExpectType Promise -playwright.seeElement(str); // $ExpectType void -playwright.dontSeeElement(str); // $ExpectType void -playwright.seeElementInDOM(str); // $ExpectType void -playwright.dontSeeElementInDOM(str); // $ExpectType void -playwright.handleDownloads(str); // $ExpectType Promise -playwright.click(str); // $ExpectType void -playwright.click(str, str); // $ExpectType void -playwright.click(str, null, { position }); // $ExpectType void -playwright.clickLink(); // $ExpectType void -playwright.forceClick(str); // $ExpectType void -playwright.focus(str); // $ExpectType void -playwright.blur(str); // $ExpectType void -playwright.doubleClick(str); // $ExpectType void -playwright.rightClick(str); // $ExpectType void -playwright.checkOption(str); // $ExpectType void -playwright.uncheckOption(str); // $ExpectType void -playwright.seeCheckboxIsChecked(str); // $ExpectType void -playwright.dontSeeCheckboxIsChecked(str); // $ExpectType void -playwright.pressKeyDown(str); // $ExpectType void -playwright.pressKeyUp(str); // $ExpectType void -playwright.pressKey(str); // $ExpectType void -playwright.type(str); // $ExpectType void -playwright.fillField(str, str); // $ExpectType void -playwright.clearField(str); // $ExpectType void -playwright.appendField(str, str); // $ExpectType void -playwright.seeInField(str, str); // $ExpectType void -playwright.dontSeeInField(str, str); // $ExpectType void -playwright.attachFile(str, str); // $ExpectType void -playwright.selectOption(str, str); // $ExpectType void -playwright.grabNumberOfVisibleElements(str); // $ExpectType Promise -playwright.seeInCurrentUrl(str); // $ExpectType void -playwright.dontSeeInCurrentUrl(str); // $ExpectType void -playwright.seeCurrentUrlEquals(str); // $ExpectType void -playwright.dontSeeCurrentUrlEquals(str); // $ExpectType void -playwright.see(str); // $ExpectType void -playwright.seeTextEquals(str); // $ExpectType void -playwright.dontSee(str); // $ExpectType void -playwright.grabSource(); // $ExpectType Promise -playwright.grabBrowserLogs(); // $ExpectType Promise -playwright.grabCurrentUrl(); // $ExpectType Promise -playwright.seeInSource(str); // $ExpectType void -playwright.dontSeeInSource(str); // $ExpectType void -playwright.seeNumberOfElements(str, num); // $ExpectType void -playwright.seeNumberOfVisibleElements(str, num); // $ExpectType void -playwright.setCookie({ name: str, value: str}); // $ExpectType void -playwright.seeCookie(str); // $ExpectType void -playwright.dontSeeCookie(str); // $ExpectType void -playwright.grabCookie(); // $ExpectType any -playwright.clearCookie(); // $ExpectType void -playwright.executeScript(() => {}); // $ExpectType Promise -playwright.grabTextFrom(str); // $ExpectType Promise -playwright.grabTextFromAll(str); // $ExpectType Promise -playwright.grabValueFrom(str); // $ExpectType Promise -playwright.grabValueFromAll(str); // $ExpectType Promise -playwright.grabHTMLFrom(str); // $ExpectType Promise -playwright.grabHTMLFromAll(str); // $ExpectType Promise -playwright.grabCssPropertyFrom(str, str); // $ExpectType Promise -playwright.grabCssPropertyFromAll(str, str); // $ExpectType Promise -playwright.seeCssPropertiesOnElements(str, str); // $ExpectType void -playwright.seeAttributesOnElements(str, str); // $ExpectType void -playwright.dragSlider(str, num); // $ExpectType void -playwright.grabAttributeFrom(str, str); // $ExpectType Promise -playwright.grabAttributeFromAll(str, str); // $ExpectType Promise -playwright.saveElementScreenshot(str, str); // $ExpectType void -playwright.saveScreenshot(str); // $ExpectType void -playwright.makeApiRequest(str, str, str); // $ExpectType Promise -playwright.wait(num); // $ExpectType void -playwright.waitForEnabled(str); // $ExpectType void -playwright.waitForValue(str, str); // $ExpectType void -playwright.waitNumberOfVisibleElements(str, num); // $ExpectType void -playwright.waitForClickable(str); // $ExpectType void -playwright.waitForElement(str); // $ExpectType void -playwright.waitForVisible(str); // $ExpectType void -playwright.waitForInvisible(str); // $ExpectType void -playwright.waitToHide(str); // $ExpectType void -playwright.waitInUrl(str); // $ExpectType void -playwright.waitUrlEquals(str); // $ExpectType void -playwright.waitForText(str); // $ExpectType void -playwright.waitForRequest(str); // $ExpectType void -playwright.waitForResponse(str); // $ExpectType void -playwright.switchTo(); // $ExpectType void -playwright.waitForFunction(() => { }); // $ExpectType void -playwright.waitForNavigation(str); // $ExpectType void -playwright.waitForDetached(str); // $ExpectType void -playwright.grabDataFromPerformanceTiming(); // $ExpectType void -playwright.grabElementBoundingRect(str); // $ExpectType Promise | Promise -playwright.mockRoute(str); // $ExpectType void -playwright.stopMockingRoute(str); // $ExpectType void +expectType(playwright.usePlaywrightTo(str, () => {})); +expectType(playwright.amAcceptingPopups()); +expectType(playwright.acceptPopup()); +expectType(playwright.amCancellingPopups()); +expectType(playwright.cancelPopup()); +expectType(playwright.seeInPopup(str)); +expectType(playwright._setPage(str)); +expectType(playwright._addPopupListener()); +expectType(playwright._getPageUrl()); +expectType>(playwright.grabPopupText()); +expectType(playwright._createContextPage()); +expectType(playwright._createContextPage({})); +expectType(playwright.amOnPage(str)); +expectType(playwright.resizeWindow(num, num)); +expectType(playwright.setPlaywrightRequestHeaders(str)); +expectType(playwright.moveCursorTo(str, num, num)); +expectError(playwright.dragAndDrop(str)); +expectType(playwright.dragAndDrop(str, str)); +expectType(playwright.dragAndDrop(str, str, { sourcePosition, targetPosition })); +expectType(playwright.restartBrowser()); +expectType(playwright.restartBrowser({})); +expectType(playwright.refreshPage()); +expectType(playwright.scrollPageToTop()); +expectType(playwright.scrollPageToBottom()); +expectType(playwright.scrollTo(str, num, num)); +expectType(playwright.seeInTitle(str)); +//playwright.grabPageScrollPosition(); +expectType(playwright.seeTitleEquals(str)); +expectType(playwright.dontSeeInTitle(str)); +expectType>(playwright.grabTitle()); +expectType(playwright._locate()); +expectType(playwright._locateCheckable()); +expectType(playwright._locateClickable()); +expectType(playwright._locateFields()); +expectType(playwright.switchToNextTab()); +expectType(playwright.switchToPreviousTab()); +expectType(playwright.closeCurrentTab()); +expectType(playwright.closeOtherTabs()); +expectType(playwright.openNewTab()); +expectType>(playwright.grabNumberOfOpenTabs()); +expectType(playwright.seeElement(str)); +expectType(playwright.dontSeeElement(str)); +expectType(playwright.seeElementInDOM(str)); +expectType(playwright.dontSeeElementInDOM(str)); +expectType>(playwright.handleDownloads(str)); +expectType(playwright.click(str)); +expectType(playwright.click(str, str)); +expectType(playwright.click(str, null, { position })); +expectType(playwright.clickLink()); +expectType(playwright.forceClick(str)); +expectType(playwright.focus(str)); +expectType(playwright.blur(str)); +expectType(playwright.doubleClick(str)); +expectType(playwright.rightClick(str)); +expectType(playwright.checkOption(str)); +expectType(playwright.uncheckOption(str)); +expectType(playwright.seeCheckboxIsChecked(str)); +expectType(playwright.dontSeeCheckboxIsChecked(str)); +expectType(playwright.pressKeyDown(str)); +expectType(playwright.pressKeyUp(str)); +expectType(playwright.pressKey(str)); +expectType(playwright.type(str)); +expectType(playwright.fillField(str, str)); +expectType(playwright.clearField(str)); +expectType(playwright.appendField(str, str)); +expectType(playwright.seeInField(str, str)); +expectType(playwright.dontSeeInField(str, str)); +expectType(playwright.attachFile(str, str)); +expectType(playwright.selectOption(str, str)); +expectType>(playwright.grabNumberOfVisibleElements(str)); +expectType(playwright.seeInCurrentUrl(str)); +expectType(playwright.dontSeeInCurrentUrl(str)); +expectType(playwright.seeCurrentUrlEquals(str)); +expectType(playwright.dontSeeCurrentUrlEquals(str)); +expectType(playwright.see(str)); +expectType(playwright.seeTextEquals(str)); +expectType(playwright.dontSee(str)); +expectType>(playwright.grabSource()); +expectType>(playwright.grabBrowserLogs()); +expectType>(playwright.grabCurrentUrl()); +expectType(playwright.seeInSource(str)); +expectType(playwright.dontSeeInSource(str)); +expectType(playwright.seeNumberOfElements(str, num)); +expectType(playwright.seeNumberOfVisibleElements(str, num)); +expectType(playwright.setCookie({ name: str, value: str })); +expectType(playwright.seeCookie(str)); +expectType(playwright.dontSeeCookie(str)); +expectType(playwright.grabCookie()); +expectType(playwright.clearCookie()); +expectType>(playwright.executeScript(() => {})); +expectType>(playwright.grabTextFrom(str)); +expectType>(playwright.grabTextFromAll(str)); +expectType>(playwright.grabValueFrom(str)); +expectType>(playwright.grabValueFromAll(str)); +expectType>(playwright.grabHTMLFrom(str)); +expectType>(playwright.grabHTMLFromAll(str)); +expectType>(playwright.grabCssPropertyFrom(str, str)); +expectType>(playwright.grabCssPropertyFromAll(str, str)); +expectType(playwright.seeCssPropertiesOnElements(str, str)); +expectType(playwright.seeAttributesOnElements(str, str)); +expectType(playwright.dragSlider(str, num)); +expectType>(playwright.grabAttributeFrom(str, str)); +expectType>(playwright.grabAttributeFromAll(str, str)); +expectType(playwright.saveElementScreenshot(str, str)); +expectType(playwright.saveScreenshot(str)); +expectType>(playwright.makeApiRequest(str, str, str)); +expectType(playwright.wait(num)); +expectType(playwright.waitForEnabled(str)); +expectType(playwright.waitForValue(str, str)); +expectType(playwright.waitNumberOfVisibleElements(str, num)); +expectType(playwright.waitForClickable(str)); +expectType(playwright.waitForElement(str)); +expectType(playwright.waitForVisible(str)); +expectType(playwright.waitForInvisible(str)); +expectType(playwright.waitToHide(str)); +expectType(playwright.waitInUrl(str)); +expectType(playwright.waitUrlEquals(str)); +expectType(playwright.waitForText(str)); +expectType(playwright.waitForRequest(str)); +expectType(playwright.waitForResponse(str)); +expectType(playwright.switchTo()); +expectType(playwright.waitForFunction(() => { })); +expectType(playwright.waitForNavigation(str)); +expectType(playwright.waitForDetached(str)); +expectType(playwright.grabDataFromPerformanceTiming()); +//expectType>(playwright.grabElementBoundingRect(str)); +expectType(playwright.mockRoute(str)); +expectType(playwright.stopMockingRoute(str)); -playwright.startRecordingTraffic(); // $ExpectType void -playwright.stopRecordingTraffic(); // $ExpectType void -playwright.seeTraffic(); // $ExpectError -playwright.seeTraffic(str); // $ExpectError -playwright.seeTraffic({ name: str }); // $ExpectError -playwright.seeTraffic({ url: str }); // $ExpectError -playwright.seeTraffic({ name: str, url: str}); // $ExpectType void -playwright.dontSeeTraffic(); // $ExpectError -playwright.dontSeeTraffic(str); // $ExpectError -playwright.dontSeeTraffic({ name: str, url: str}); // $ExpectType void -playwright.dontSeeTraffic({ name: str, url: /hello/}); // $ExpectType void -playwright.dontSeeTraffic({ name: str }); // $ExpectError -playwright.dontSeeTraffic({ url: str }); // $ExpectError +expectType(playwright.startRecordingTraffic()); +expectType(playwright.stopRecordingTraffic()); +expectError(playwright.seeTraffic()); +expectError(playwright.seeTraffic(str)); +expectError(playwright.seeTraffic({ name: str })); +expectError(playwright.seeTraffic({ url: str })); +expectType(playwright.seeTraffic({ name: str, url: str })); +expectError(playwright.dontSeeTraffic()); +expectError(playwright.dontSeeTraffic(str)); +expectType(playwright.dontSeeTraffic({ name: str, url: str })); +expectType(playwright.dontSeeTraffic({ name: str, url: /hello/ })); +expectError(playwright.dontSeeTraffic({ name: str })); +expectError(playwright.dontSeeTraffic({ url: str })); diff --git a/typings/tests/helpers/PlaywrightTs.types.ts b/typings/tests/helpers/PlaywrightTs.types.ts index 2e014e88f..2dadbbd17 100644 --- a/typings/tests/helpers/PlaywrightTs.types.ts +++ b/typings/tests/helpers/PlaywrightTs.types.ts @@ -1,5 +1,6 @@ -export {}; // mark the file as external module to redeclare variables in the same block +import { expectError, expectType } from 'tsd'; +// @ts-ignore const playwright = new CodeceptJS.PlaywrightTs(); const str = 'text'; @@ -8,141 +9,141 @@ const position = { x: 100, y: 200 }; const sourcePosition = { x: 10, y: 20 }; const targetPosition = { x: 20, y: 30 }; -playwright.usePlaywrightTo(str, () => {}); // $ExpectType Promise -playwright.amAcceptingPopups(); // $ExpectType Promise -playwright.acceptPopup(); // $ExpectType Promise -playwright.amCancellingPopups(); // $ExpectType Promise -playwright.cancelPopup(); // $ExpectType Promise -playwright.seeInPopup(str); // $ExpectType Promise -playwright._setPage(str); // $ExpectType Promise -playwright._addPopupListener(); // $ExpectType Promise -playwright._getPageUrl(); // $ExpectType Promise -playwright.grabPopupText(); // $ExpectType Promise -playwright.amOnPage(str); // $ExpectType Promise -playwright.resizeWindow(num, num); // $ExpectType Promise -playwright.setPlaywrightRequestHeaders(str); // $ExpectType Promise -playwright.moveCursorTo(str, num, num); // $ExpectType Promise -playwright.dragAndDrop(str); // $ExpectError -playwright.dragAndDrop(str, str); // $ExpectType Promise -playwright.dragAndDrop(str, str, { sourcePosition, targetPosition }); // $ExpectType Promise -playwright.refreshPage(); // $ExpectType Promise -playwright.scrollPageToTop(); // $ExpectType Promise -playwright.scrollPageToBottom(); // $ExpectType Promise -playwright.scrollTo(str, num, num); // $ExpectType Promise -playwright.seeInTitle(str); // $ExpectType Promise -playwright.grabPageScrollPosition(); // $ExpectType Promise -playwright.seeTitleEquals(str); // $ExpectType Promise -playwright.dontSeeInTitle(str); // $ExpectType Promise -playwright.grabTitle(); // $ExpectType Promise -playwright._locate(); // $ExpectType Promise -playwright._locateCheckable(); // $ExpectType Promise -playwright._locateClickable(); // $ExpectType Promise -playwright._locateFields(); // $ExpectType Promise -playwright.switchToNextTab(); // $ExpectType Promise -playwright.switchToPreviousTab(); // $ExpectType Promise -playwright.closeCurrentTab(); // $ExpectType Promise -playwright.closeOtherTabs(); // $ExpectType Promise -playwright.openNewTab(); // $ExpectType Promise -playwright.grabNumberOfOpenTabs(); // $ExpectType Promise -playwright.seeElement(str); // $ExpectType Promise -playwright.dontSeeElement(str); // $ExpectType Promise -playwright.seeElementInDOM(str); // $ExpectType Promise -playwright.dontSeeElementInDOM(str); // $ExpectType Promise -playwright.handleDownloads(str); // $ExpectType Promise -playwright.click(str); // $ExpectType Promise -playwright.click(str, str); // $ExpectType Promise -playwright.click(str, null, { position }); // $ExpectType Promise -playwright.clickLink(); // $ExpectType Promise -playwright.forceClick(str); // $ExpectType Promise -playwright.focus(str); // $ExpectType Promise -playwright.blur(str); // $ExpectType Promise -playwright.doubleClick(str); // $ExpectType Promise -playwright.rightClick(str); // $ExpectType Promise -playwright.checkOption(str); // $ExpectType Promise -playwright.uncheckOption(str); // $ExpectType Promise -playwright.seeCheckboxIsChecked(str); // $ExpectType Promise -playwright.dontSeeCheckboxIsChecked(str); // $ExpectType Promise -playwright.pressKeyDown(str); // $ExpectType Promise -playwright.pressKeyUp(str); // $ExpectType Promise -playwright.pressKey(str); // $ExpectType Promise -playwright.type(str); // $ExpectType Promise -playwright.fillField(str, str); // $ExpectType Promise -playwright.clearField(str); // $ExpectType Promise -playwright.appendField(str, str); // $ExpectType Promise -playwright.seeInField(str, str); // $ExpectType Promise -playwright.dontSeeInField(str, str); // $ExpectType Promise -playwright.attachFile(str, str); // $ExpectType Promise -playwright.selectOption(str, str); // $ExpectType Promise -playwright.grabNumberOfVisibleElements(str); // $ExpectType Promise -playwright.seeInCurrentUrl(str); // $ExpectType Promise -playwright.dontSeeInCurrentUrl(str); // $ExpectType Promise -playwright.seeCurrentUrlEquals(str); // $ExpectType Promise -playwright.dontSeeCurrentUrlEquals(str); // $ExpectType Promise -playwright.see(str); // $ExpectType Promise -playwright.seeTextEquals(str); // $ExpectType Promise -playwright.dontSee(str); // $ExpectType Promise -playwright.grabSource(); // $ExpectType Promise -playwright.grabBrowserLogs(); // $ExpectType Promise -playwright.grabCurrentUrl(); // $ExpectType Promise -playwright.seeInSource(str); // $ExpectType Promise -playwright.dontSeeInSource(str); // $ExpectType Promise -playwright.seeNumberOfElements(str, num); // $ExpectType Promise -playwright.seeNumberOfVisibleElements(str, num); // $ExpectType Promise -playwright.setCookie({ name: str, value: str}); // $ExpectType Promise -playwright.seeCookie(str); // $ExpectType Promise -playwright.dontSeeCookie(str); // $ExpectType Promise -playwright.grabCookie(); // $ExpectType Promise -playwright.clearCookie(); // $ExpectType Promise -playwright.executeScript(() => {}); // $ExpectType Promise -playwright.grabTextFrom(str); // $ExpectType Promise -playwright.grabTextFromAll(str); // $ExpectType Promise -playwright.grabValueFrom(str); // $ExpectType Promise -playwright.grabValueFromAll(str); // $ExpectType Promise -playwright.grabHTMLFrom(str); // $ExpectType Promise -playwright.grabHTMLFromAll(str); // $ExpectType Promise -playwright.grabCssPropertyFrom(str, str); // $ExpectType Promise -playwright.grabCssPropertyFromAll(str, str); // $ExpectType Promise -playwright.seeCssPropertiesOnElements(str, str); // $ExpectType Promise -playwright.seeAttributesOnElements(str, str); // $ExpectType Promise -playwright.dragSlider(str, num); // $ExpectType Promise -playwright.grabAttributeFrom(str, str); // $ExpectType Promise -playwright.grabAttributeFromAll(str, str); // $ExpectType Promise -playwright.saveElementScreenshot(str, str); // $ExpectType Promise -playwright.saveScreenshot(str); // $ExpectType Promise -playwright.makeApiRequest(str, str, str); // $ExpectType Promise -playwright.wait(num); // $ExpectType Promise -playwright.waitForEnabled(str); // $ExpectType Promise -playwright.waitForValue(str, str); // $ExpectType Promise -playwright.waitNumberOfVisibleElements(str, num); // $ExpectType Promise -playwright.waitForClickable(str); // $ExpectType Promise -playwright.waitForElement(str); // $ExpectType Promise -playwright.waitForVisible(str); // $ExpectType Promise -playwright.waitForInvisible(str); // $ExpectType Promise -playwright.waitToHide(str); // $ExpectType Promise -playwright.waitInUrl(str); // $ExpectType Promise -playwright.waitUrlEquals(str); // $ExpectType Promise -playwright.waitForText(str); // $ExpectType Promise -playwright.waitForRequest(str); // $ExpectType Promise -playwright.waitForResponse(str); // $ExpectType Promise -playwright.switchTo(); // $ExpectType Promise -playwright.waitForFunction(() => { }); // $ExpectType Promise -playwright.waitForNavigation(str); // $ExpectType Promise -playwright.waitForDetached(str); // $ExpectType Promise -playwright.grabDataFromPerformanceTiming(); // $ExpectType Promise -playwright.grabElementBoundingRect(str); // $ExpectType Promise | Promise -playwright.mockRoute(str); // $ExpectType Promise -playwright.stopMockingRoute(str); // $ExpectType Promise +expectType>(playwright.usePlaywrightTo(str, () => {})); +expectType>(playwright.amAcceptingPopups()); +expectType>(playwright.acceptPopup()); +expectType>(playwright.amCancellingPopups()); +expectType>(playwright.cancelPopup()); +expectType>(playwright.seeInPopup(str)); +expectType>(playwright._setPage(str)); +expectType>(playwright._addPopupListener()); +expectType>(playwright._getPageUrl()); +expectType>(playwright.grabPopupText()); +expectType>(playwright.amOnPage(str)); +expectType>(playwright.resizeWindow(num, num)); +expectType>(playwright.setPlaywrightRequestHeaders(str)); +expectType>(playwright.moveCursorTo(str, num, num)); +expectError(playwright.dragAndDrop(str)); +expectType>(playwright.dragAndDrop(str, str)); +expectType>(playwright.dragAndDrop(str, str, { sourcePosition, targetPosition })); +expectType>(playwright.refreshPage()); +expectType>(playwright.scrollPageToTop()); +expectType>(playwright.scrollPageToBottom()); +expectType>(playwright.scrollTo(str, num, num)); +expectType>(playwright.seeInTitle(str)); +//expectType>(playwright.grabPageScrollPosition()); +expectType>(playwright.seeTitleEquals(str)); +expectType>(playwright.dontSeeInTitle(str)); +expectType>(playwright.grabTitle()); +expectType>(playwright._locate()); +expectType>(playwright._locateCheckable()); +expectType>(playwright._locateClickable()); +expectType>(playwright._locateFields()); +expectType>(playwright.switchToNextTab()); +expectType>(playwright.switchToPreviousTab()); +expectType>(playwright.closeCurrentTab()); +expectType>(playwright.closeOtherTabs()); +expectType>(playwright.openNewTab()); +expectType>(playwright.grabNumberOfOpenTabs()); +expectType>(playwright.seeElement(str)); +expectType>(playwright.dontSeeElement(str)); +expectType>(playwright.seeElementInDOM(str)); +expectType>(playwright.dontSeeElementInDOM(str)); +expectType>(playwright.handleDownloads(str)); +expectType>(playwright.click(str)); +expectType>(playwright.click(str, str)); +expectType>(playwright.click(str, null, { position })); +expectType>(playwright.clickLink()); +expectType>(playwright.forceClick(str)); +expectType>(playwright.focus(str)); +expectType>(playwright.blur(str)); +expectType>(playwright.doubleClick(str)); +expectType>(playwright.rightClick(str)); +expectType>(playwright.checkOption(str)); +expectType>(playwright.uncheckOption(str)); +expectType>(playwright.seeCheckboxIsChecked(str)); +expectType>(playwright.dontSeeCheckboxIsChecked(str)); +expectType>(playwright.pressKeyDown(str)); +expectType>(playwright.pressKeyUp(str)); +expectType>(playwright.pressKey(str)); +expectType>(playwright.type(str)); +expectType>(playwright.fillField(str, str)); +expectType>(playwright.clearField(str)); +expectType>(playwright.appendField(str, str)); +expectType>(playwright.seeInField(str, str)); +expectType>(playwright.dontSeeInField(str, str)); +expectType>(playwright.attachFile(str, str)); +expectType>(playwright.selectOption(str, str)); +expectType>(playwright.grabNumberOfVisibleElements(str)); +expectType>(playwright.seeInCurrentUrl(str)); +expectType>(playwright.dontSeeInCurrentUrl(str)); +expectType>(playwright.seeCurrentUrlEquals(str)); +expectType>(playwright.dontSeeCurrentUrlEquals(str)); +expectType>(playwright.see(str)); +expectType>(playwright.seeTextEquals(str)); +expectType>(playwright.dontSee(str)); +expectType>(playwright.grabSource()); +expectType>(playwright.grabBrowserLogs()); +expectType>(playwright.grabCurrentUrl()); +expectType>(playwright.seeInSource(str)); +expectType>(playwright.dontSeeInSource(str)); +expectType>(playwright.seeNumberOfElements(str, num)); +expectType>(playwright.seeNumberOfVisibleElements(str, num)); +expectType>(playwright.setCookie({ name: str, value: str })); +expectType>(playwright.seeCookie(str)); +expectType>(playwright.dontSeeCookie(str)); +expectType>(playwright.grabCookie()); +expectType>(playwright.clearCookie()); +expectType>(playwright.executeScript(() => {})); +expectType>(playwright.grabTextFrom(str)); +expectType>(playwright.grabTextFromAll(str)); +expectType>(playwright.grabValueFrom(str)); +expectType>(playwright.grabValueFromAll(str)); +expectType>(playwright.grabHTMLFrom(str)); +expectType>(playwright.grabHTMLFromAll(str)); +expectType>(playwright.grabCssPropertyFrom(str, str)); +expectType>(playwright.grabCssPropertyFromAll(str, str)); +expectType>(playwright.seeCssPropertiesOnElements(str, str)); +expectType>(playwright.seeAttributesOnElements(str, str)); +expectType>(playwright.dragSlider(str, num)); +expectType>(playwright.grabAttributeFrom(str, str)); +expectType>(playwright.grabAttributeFromAll(str, str)); +expectType>(playwright.saveElementScreenshot(str, str)); +expectType>(playwright.saveScreenshot(str)); +expectType>(playwright.makeApiRequest(str, str, str)); +expectType>(playwright.wait(num)); +expectType>(playwright.waitForEnabled(str)); +expectType>(playwright.waitForValue(str, str)); +expectType>(playwright.waitNumberOfVisibleElements(str, num)); +expectType>(playwright.waitForClickable(str)); +expectType>(playwright.waitForElement(str)); +expectType>(playwright.waitForVisible(str)); +expectType>(playwright.waitForInvisible(str)); +expectType>(playwright.waitToHide(str)); +expectType>(playwright.waitInUrl(str)); +expectType>(playwright.waitUrlEquals(str)); +expectType>(playwright.waitForText(str)); +expectType>(playwright.waitForRequest(str)); +expectType>(playwright.waitForResponse(str)); +expectType>(playwright.switchTo()); +expectType>(playwright.waitForFunction(() => { })); +expectType>(playwright.waitForNavigation(str)); +expectType>(playwright.waitForDetached(str)); +expectType>(playwright.grabDataFromPerformanceTiming()); +//expectType>(playwright.grabElementBoundingRect(str)); +expectType>(playwright.mockRoute(str)); +expectType>(playwright.stopMockingRoute(str)); -playwright.startRecordingTraffic(); // $ExpectType Promise -playwright.stopRecordingTraffic(); // $ExpectType Promise -playwright.seeTraffic(); // $ExpectError -playwright.seeTraffic(str); // $ExpectError -playwright.seeTraffic({ name: str, url: str}); // $ExpectType Promise -playwright.seeTraffic({ name: str }); // $ExpectError -playwright.seeTraffic({ url: str }); // $ExpectError -playwright.dontSeeTraffic(); // $ExpectError -playwright.dontSeeTraffic(str); // $ExpectError -playwright.dontSeeTraffic({ name: str, url: str}); // $ExpectType Promise -playwright.dontSeeTraffic({ name: str, url: /hello/}); // $ExpectType Promise -playwright.dontSeeTraffic({ name: str }); // $ExpectError -playwright.dontSeeTraffic({ url: str }); // $ExpectError +expectType>(playwright.startRecordingTraffic()); +expectType>(playwright.stopRecordingTraffic()); +expectError(playwright.seeTraffic()); +expectError(playwright.seeTraffic(str)); +expectType>(playwright.seeTraffic({ name: str, url: str })); +expectError(playwright.seeTraffic({ name: str })); +expectError(playwright.seeTraffic({ url: str })); +expectError(playwright.dontSeeTraffic()); +expectError(playwright.dontSeeTraffic(str)); +expectType>(playwright.dontSeeTraffic({ name: str, url: str })); +expectType>(playwright.dontSeeTraffic({ name: str, url: /hello/ })); +expectError(playwright.dontSeeTraffic({ name: str })); +expectError(playwright.dontSeeTraffic({ url: str })); diff --git a/typings/tests/helpers/WebDriverIO.types.ts b/typings/tests/helpers/WebDriverIO.types.ts index 1ff4a86e6..137f55e7e 100644 --- a/typings/tests/helpers/WebDriverIO.types.ts +++ b/typings/tests/helpers/WebDriverIO.types.ts @@ -1,23 +1,26 @@ -export {}; // mark the file as external module to redeclare variables in the same block +import { expectError, expectType } from 'tsd'; +// @ts-ignore const wd = new CodeceptJS.WebDriver(); const str = 'text'; const num = 1; -wd.amOnPage(); // $ExpectError -wd.amOnPage(''); // $ExpectType void +expectError(wd.amOnPage()); +expectType(wd.amOnPage('')); -wd.focus(); // $ExpectError -wd.focus('div'); // $ExpectType void +expectError(wd.focus()); +expectType(wd.focus('div')); wd.focus({ css: 'div' }); wd.focus({ xpath: '//div' }); wd.focus({ name: 'div' }); wd.focus({ id: 'div' }); wd.focus({ android: 'div' }); wd.focus({ ios: 'div' }); +// @ts-ignore wd.focus(locate('div')); wd.focus('div', 'body'); +// @ts-ignore wd.focus('div', locate('div')); wd.focus('div', { css: 'div' }); wd.focus('div', { xpath: '//div' }); @@ -26,16 +29,18 @@ wd.focus('div', { id: '//div' }); wd.focus('div', { android: '//div' }); wd.focus('div', { ios: '//div' }); -wd.blur(); // $ExpectError -wd.blur('div'); // $ExpectType void +expectError(wd.blur()); +expectType(wd.blur('div')); wd.blur({ css: 'div' }); wd.blur({ xpath: '//div' }); wd.blur({ name: 'div' }); wd.blur({ id: 'div' }); wd.blur({ android: 'div' }); wd.blur({ ios: 'div' }); +// @ts-ignore wd.blur(locate('div')); wd.blur('div', 'body'); +// @ts-ignore wd.blur('div', locate('div')); wd.blur('div', { css: 'div' }); wd.blur('div', { xpath: '//div' }); @@ -44,16 +49,18 @@ wd.blur('div', { id: '//div' }); wd.blur('div', { android: '//div' }); wd.blur('div', { ios: '//div' }); -wd.click(); // $ExpectError -wd.click('div'); // $ExpectType void +expectError(wd.click()); +expectType(wd.click('div')); wd.click({ css: 'div' }); wd.click({ xpath: '//div' }); wd.click({ name: 'div' }); wd.click({ id: 'div' }); wd.click({ android: 'div' }); wd.click({ ios: 'div' }); +// @ts-ignore wd.click(locate('div')); wd.click('div', 'body'); +// @ts-ignore wd.click('div', locate('div')); wd.click('div', { css: 'div' }); wd.click('div', { xpath: '//div' }); @@ -62,16 +69,18 @@ wd.click('div', { id: '//div' }); wd.click('div', { android: '//div' }); wd.click('div', { ios: '//div' }); -wd.forceClick(); // $ExpectError -wd.forceClick('div'); // $ExpectType void +expectError(wd.forceClick()); +expectType(wd.forceClick('div')); wd.forceClick({ css: 'div' }); wd.forceClick({ xpath: '//div' }); wd.forceClick({ name: 'div' }); wd.forceClick({ id: 'div' }); wd.forceClick({ android: 'div' }); wd.forceClick({ ios: 'div' }); +// @ts-ignore wd.forceClick(locate('div')); wd.forceClick('div', 'body'); +// @ts-ignore wd.forceClick('div', locate('div')); wd.forceClick('div', { css: 'div' }); wd.forceClick('div', { xpath: '//div' }); @@ -80,16 +89,18 @@ wd.forceClick('div', { id: '//div' }); wd.forceClick('div', { android: '//div' }); wd.forceClick('div', { ios: '//div' }); -wd.doubleClick(); // $ExpectError -wd.doubleClick('div'); // $ExpectType void +expectError(wd.doubleClick()); +expectType(wd.doubleClick('div')); wd.doubleClick({ css: 'div' }); wd.doubleClick({ xpath: '//div' }); wd.doubleClick({ name: 'div' }); wd.doubleClick({ id: 'div' }); wd.doubleClick({ android: 'div' }); wd.doubleClick({ ios: 'div' }); +// @ts-ignore wd.doubleClick(locate('div')); wd.doubleClick('div', 'body'); +// @ts-ignore wd.doubleClick('div', locate('div')); wd.doubleClick('div', { css: 'div' }); wd.doubleClick('div', { xpath: '//div' }); @@ -98,16 +109,18 @@ wd.doubleClick('div', { id: '//div' }); wd.doubleClick('div', { android: '//div' }); wd.doubleClick('div', { ios: '//div' }); -wd.rightClick(); // $ExpectError -wd.rightClick('div'); // $ExpectType void +expectError(wd.rightClick()); +expectType(wd.rightClick('div')); wd.rightClick({ css: 'div' }); wd.rightClick({ xpath: '//div' }); wd.rightClick({ name: 'div' }); wd.rightClick({ id: 'div' }); wd.rightClick({ android: 'div' }); wd.rightClick({ ios: 'div' }); +// @ts-ignore wd.rightClick(locate('div')); wd.rightClick('div', 'body'); +// @ts-ignore wd.rightClick('div', locate('div')); wd.rightClick('div', { css: 'div' }); wd.rightClick('div', { xpath: '//div' }); @@ -116,29 +129,31 @@ wd.rightClick('div', { id: '//div' }); wd.rightClick('div', { android: '//div' }); wd.rightClick('div', { ios: '//div' }); -wd.fillField(); // $ExpectError -wd.fillField('div'); // $ExpectError -wd.fillField('div', str); // $ExpectType void +expectError(wd.fillField()); +expectError(wd.fillField('div')); +expectType(wd.fillField('div', str)); wd.fillField({ css: 'div' }, str); wd.fillField({ xpath: '//div' }, str); wd.fillField({ name: 'div' }, str); wd.fillField({ id: 'div' }, str); wd.fillField({ android: 'div' }, str); wd.fillField({ ios: 'div' }, str); +// @ts-ignore wd.fillField(locate('div'), str); -wd.appendField(); // $ExpectError -wd.appendField('div'); // $ExpectError -wd.appendField('div', str); // $ExpectType void +expectError(wd.appendField()); +expectError(wd.appendField('div')); +expectType(wd.appendField('div', str)); wd.appendField({ css: 'div' }, str); wd.appendField({ xpath: '//div' }, str); wd.appendField({ name: 'div' }, str); wd.appendField({ id: 'div' }, str); wd.appendField({ android: 'div' }, str); wd.appendField({ ios: 'div' }, str); +// @ts-ignore wd.appendField(locate('div'), str); -wd.clearField(); // $ExpectError +expectError(wd.clearField()); wd.clearField('div'); wd.clearField({ css: 'div' }); wd.clearField({ xpath: '//div' }); @@ -147,315 +162,315 @@ wd.clearField({ id: 'div' }); wd.clearField({ android: 'div' }); wd.clearField({ ios: 'div' }); -wd.selectOption(); // $ExpectError -wd.selectOption('div'); // $ExpectError -wd.selectOption('div', str); // $ExpectType void +expectError(wd.selectOption()); +expectError(wd.selectOption('div')); +expectType(wd.selectOption('div', str)); -wd.attachFile(); // $ExpectError -wd.attachFile('div'); // $ExpectError -wd.attachFile('div', str); // $ExpectType void +expectError(wd.attachFile()); +expectError(wd.attachFile('div')); +expectType(wd.attachFile('div', str)); -wd.checkOption(); // $ExpectError -wd.checkOption('div'); // $ExpectType void +expectError(wd.checkOption()); +expectType(wd.checkOption('div')); -wd.uncheckOption(); // $ExpectError -wd.uncheckOption('div'); // $ExpectType void +expectError(wd.uncheckOption()); +expectType(wd.uncheckOption('div')); -wd.seeInTitle(); // $ExpectError -wd.seeInTitle(str); // $ExpectType void +expectError(wd.seeInTitle()); +expectType(wd.seeInTitle(str)); -wd.seeTitleEquals(); // $ExpectError -wd.seeTitleEquals(str); // $ExpectType void +expectError(wd.seeTitleEquals()); +expectType(wd.seeTitleEquals(str)); -wd.dontSeeInTitle(); // $ExpectError -wd.dontSeeInTitle(str); // $ExpectType void +expectError(wd.dontSeeInTitle()); +expectType(wd.dontSeeInTitle(str)); -wd.see(); // $ExpectError -wd.see(str); // $ExpectType void -wd.see(str, 'div'); // $ExpectType void +expectError(wd.see()); +expectType(wd.see(str)); +expectType(wd.see(str, 'div')); -wd.dontSee(); // $ExpectError -wd.dontSee(str); // $ExpectType void -wd.dontSee(str, 'div'); // $ExpectType void +expectError(wd.dontSee()); +expectType(wd.dontSee(str)); +expectType(wd.dontSee(str, 'div')); -wd.seeTextEquals(); // $ExpectError -wd.seeTextEquals(str); // $ExpectType void -wd.seeTextEquals(str, 'div'); // $ExpectType void +expectError(wd.seeTextEquals()); +expectType(wd.seeTextEquals(str)); +expectType(wd.seeTextEquals(str, 'div')); -wd.seeInField(); // $ExpectError -wd.seeInField('div'); // $ExpectError -wd.seeInField('div', str); // $ExpectType void +expectError(wd.seeInField()); +expectError(wd.seeInField('div')); +expectType(wd.seeInField('div', str)); -wd.dontSeeInField(); // $ExpectError -wd.dontSeeInField('div'); // $ExpectError -wd.dontSeeInField('div', str); // $ExpectType void +expectError(wd.dontSeeInField()); +expectError(wd.dontSeeInField('div')); +expectType(wd.dontSeeInField('div', str)); -wd.seeCheckboxIsChecked(); // $ExpectError -wd.seeCheckboxIsChecked('div'); // $ExpectType void +expectError(wd.seeCheckboxIsChecked()); +expectType(wd.seeCheckboxIsChecked('div')); -wd.dontSeeCheckboxIsChecked(); // $ExpectError -wd.dontSeeCheckboxIsChecked('div'); // $ExpectType void +expectError(wd.dontSeeCheckboxIsChecked()); +expectType(wd.dontSeeCheckboxIsChecked('div')); -wd.seeElement(); // $ExpectError -wd.seeElement('div'); // $ExpectType void +expectError(wd.seeElement()); +expectType(wd.seeElement('div')); -wd.dontSeeElement(); // $ExpectError -wd.dontSeeElement('div'); // $ExpectType void +expectError(wd.dontSeeElement()); +expectType(wd.dontSeeElement('div')); -wd.seeElementInDOM(); // $ExpectError -wd.seeElementInDOM('div'); // $ExpectType void +expectError(wd.seeElementInDOM()); +expectType(wd.seeElementInDOM('div')); -wd.dontSeeElementInDOM(); // $ExpectError -wd.dontSeeElementInDOM('div'); // $ExpectType void +expectError(wd.dontSeeElementInDOM()); +expectType(wd.dontSeeElementInDOM('div')); -wd.seeInSource(); // $ExpectError -wd.seeInSource(str); // $ExpectType void +expectError(wd.seeInSource()); +expectType(wd.seeInSource(str)); -wd.dontSeeInSource(); // $ExpectError -wd.dontSeeInSource(str); // $ExpectType void +expectError(wd.dontSeeInSource()); +expectType(wd.dontSeeInSource(str)); -wd.seeNumberOfElements(); // $ExpectError -wd.seeNumberOfElements('div'); // $ExpectError -wd.seeNumberOfElements('div', num); // $ExpectType void +expectError(wd.seeNumberOfElements()); +expectError(wd.seeNumberOfElements('div')); +expectType(wd.seeNumberOfElements('div', num)); -wd.seeNumberOfVisibleElements(); // $ExpectError -wd.seeNumberOfVisibleElements('div'); // $ExpectError -wd.seeNumberOfVisibleElements('div', num); // $ExpectType void +expectError(wd.seeNumberOfVisibleElements()); +expectError(wd.seeNumberOfVisibleElements('div')); +expectType(wd.seeNumberOfVisibleElements('div', num)); -wd.seeCssPropertiesOnElements(); // $ExpectError -wd.seeCssPropertiesOnElements('div'); // $ExpectError -wd.seeCssPropertiesOnElements('div', str); // $ExpectType void +expectError(wd.seeCssPropertiesOnElements()); +expectError(wd.seeCssPropertiesOnElements('div')); +expectType(wd.seeCssPropertiesOnElements('div', str)); -wd.seeAttributesOnElements(); // $ExpectError -wd.seeAttributesOnElements('div'); // $ExpectError -wd.seeAttributesOnElements('div', str); // $ExpectType void +expectError(wd.seeAttributesOnElements()); +expectError(wd.seeAttributesOnElements('div')); +expectType(wd.seeAttributesOnElements('div', str)); -wd.seeInCurrentUrl(); // $ExpectError -wd.seeInCurrentUrl(str); // $ExpectType void +expectError(wd.seeInCurrentUrl()); +expectType(wd.seeInCurrentUrl(str)); -wd.seeCurrentUrlEquals(); // $ExpectError -wd.seeCurrentUrlEquals(str); // $ExpectType void +expectError(wd.seeCurrentUrlEquals()); +expectType(wd.seeCurrentUrlEquals(str)); -wd.dontSeeInCurrentUrl(); // $ExpectError -wd.dontSeeInCurrentUrl(str); // $ExpectType void +expectError(wd.dontSeeInCurrentUrl()); +expectType(wd.dontSeeInCurrentUrl(str)); -wd.dontSeeCurrentUrlEquals(); // $ExpectError -wd.dontSeeCurrentUrlEquals(str); // $ExpectType void +expectError(wd.dontSeeCurrentUrlEquals()); +expectType(wd.dontSeeCurrentUrlEquals(str)); -wd.executeScript(); // $ExpectError -wd.executeScript(str); // $ExpectType Promise -wd.executeScript(() => {}); // $ExpectType Promise -wd.executeScript(() => {}, {}); // $ExpectType Promise +expectError(wd.executeScript()); +expectType>(wd.executeScript(str)); +expectType>(wd.executeScript(() => {})); +expectType>(wd.executeScript(() => {}, {})); -wd.executeAsyncScript(); // $ExpectError -wd.executeAsyncScript(str); // $ExpectType Promise -wd.executeAsyncScript(() => {}); // $ExpectType Promise -wd.executeAsyncScript(() => {}, {}); // $ExpectType Promise +expectError(wd.executeAsyncScript()); +expectType>(wd.executeAsyncScript(str)); +expectType>(wd.executeAsyncScript(() => {})); +expectType>(wd.executeAsyncScript(() => {}, {})); -wd.scrollIntoView(); // $ExpectError -wd.scrollIntoView('div'); // $ExpectError +expectError(wd.scrollIntoView()); +expectError(wd.scrollIntoView('div')); wd.scrollIntoView('div', true); wd.scrollIntoView('div', { behavior: 'auto', block: 'center', inline: 'center' }); -wd.scrollTo(); // $ExpectError -wd.scrollTo('div'); // $ExpectType void -wd.scrollTo('div', num, num); // $ExpectType void +expectError(wd.scrollTo()); +expectType(wd.scrollTo('div')); +expectType(wd.scrollTo('div', num, num)); -wd.moveCursorTo(); // $ExpectError -wd.moveCursorTo('div'); // $ExpectType void -wd.moveCursorTo('div', num, num); // $ExpectType void +expectError(wd.moveCursorTo()); +expectType(wd.moveCursorTo('div')); +expectType(wd.moveCursorTo('div', num, num)); -wd.saveScreenshot(); // $ExpectError -wd.saveScreenshot(str); // $ExpectType void -wd.saveScreenshot(str, true); // $ExpectType void +expectError(wd.saveScreenshot()); +expectType(wd.saveScreenshot(str)); +expectType(wd.saveScreenshot(str, true)); -wd.setCookie(); // $ExpectError -wd.setCookie({ name: str, value: str }); // $ExpectType void -wd.setCookie([{ name: str, value: str }]); // $ExpectType void +expectError(wd.setCookie()); +expectType(wd.setCookie({ name: str, value: str })); +expectType(wd.setCookie([{ name: str, value: str }])); -wd.clearCookie(); // $ExpectType void -wd.clearCookie(str); // $ExpectType void +expectType(wd.clearCookie()); +expectType(wd.clearCookie(str)); -wd.seeCookie(); // $ExpectError -wd.seeCookie(str); // $ExpectType void +expectError(wd.seeCookie()); +expectType(wd.seeCookie(str)); -wd.acceptPopup(); // $ExpectType void +expectType(wd.acceptPopup()); -wd.cancelPopup(); // $ExpectType void +expectType(wd.cancelPopup()); -wd.seeInPopup(); // $ExpectError -wd.seeInPopup(str); // $ExpectType void +expectError(wd.seeInPopup()); +expectType(wd.seeInPopup(str)); -wd.pressKeyDown(); // $ExpectError -wd.pressKeyDown(str); // $ExpectType void +expectError(wd.pressKeyDown()); +expectType(wd.pressKeyDown(str)); -wd.pressKeyUp(); // $ExpectError -wd.pressKeyUp(str); // $ExpectType void +expectError(wd.pressKeyUp()); +expectType(wd.pressKeyUp(str)); -wd.pressKey(); // $ExpectError -wd.pressKey(str); // $ExpectType void +expectError(wd.pressKey()); +expectType(wd.pressKey(str)); -wd.type(); // $ExpectError -wd.type(str); // $ExpectType void +expectError(wd.type()); +expectType(wd.type(str)); -wd.resizeWindow(); // $ExpectError -wd.resizeWindow(num); // $ExpectError -wd.resizeWindow(num, num); // $ExpectType void +expectError(wd.resizeWindow()); +expectError(wd.resizeWindow(num)); +expectType(wd.resizeWindow(num, num)); -wd.dragAndDrop(); // $ExpectError -wd.dragAndDrop('div'); // $ExpectError -wd.dragAndDrop('div', 'div'); // $ExpectType void +expectError(wd.dragAndDrop()); +expectError(wd.dragAndDrop('div')); +expectType(wd.dragAndDrop('div', 'div')); -wd.dragSlider(); // $ExpectError -wd.dragSlider('div', num); // $ExpectType void +expectError(wd.dragSlider()); +expectType(wd.dragSlider('div', num)); -wd.switchToWindow(); // $ExpectError -wd.switchToWindow(str); // $ExpectType void +expectError(wd.switchToWindow()); +expectType(wd.switchToWindow(str)); -wd.closeOtherTabs(); // $ExpectType void +expectType(wd.closeOtherTabs()); -wd.wait(); // $ExpectError -wd.wait(num); // $ExpectType void +expectError(wd.wait()); +expectType(wd.wait(num)); -wd.waitForEnabled(); // $ExpectError -wd.waitForEnabled('div'); // $ExpectType void -wd.waitForEnabled('div', num); // $ExpectType void +expectError(wd.waitForEnabled()); +expectType(wd.waitForEnabled('div')); +expectType(wd.waitForEnabled('div', num)); -wd.waitForElement(); // $ExpectError -wd.waitForElement('div'); // $ExpectType void -wd.waitForElement('div', num); // $ExpectType void +expectError(wd.waitForElement()); +expectType(wd.waitForElement('div')); +expectType(wd.waitForElement('div', num)); -wd.waitForClickable(); // $ExpectError -wd.waitForClickable('div'); // $ExpectType void -wd.waitForClickable('div', num); // $ExpectType void +expectError(wd.waitForClickable()); +expectType(wd.waitForClickable('div')); +expectType(wd.waitForClickable('div', num)); -wd.waitForVisible(); // $ExpectError -wd.waitForVisible('div'); // $ExpectType void -wd.waitForVisible('div', num); // $ExpectType void +expectError(wd.waitForVisible()); +expectType(wd.waitForVisible('div')); +expectType(wd.waitForVisible('div', num)); -wd.waitForInvisible(); // $ExpectError -wd.waitForInvisible('div'); // $ExpectType void -wd.waitForInvisible('div', num); // $ExpectType void +expectError(wd.waitForInvisible()); +expectType(wd.waitForInvisible('div')); +expectType(wd.waitForInvisible('div', num)); -wd.waitToHide(); // $ExpectError -wd.waitToHide('div'); // $ExpectType void -wd.waitToHide('div', num); // $ExpectType void +expectError(wd.waitToHide()); +expectType(wd.waitToHide('div')); +expectType(wd.waitToHide('div', num)); -wd.waitForDetached(); // $ExpectError -wd.waitForDetached('div'); // $ExpectType void -wd.waitForDetached('div', num); // $ExpectType void +expectError(wd.waitForDetached()); +expectType(wd.waitForDetached('div')); +expectType(wd.waitForDetached('div', num)); -wd.waitForFunction(); // $ExpectError -wd.waitForFunction('div'); // $ExpectType void -wd.waitForFunction(() => {}); // $ExpectType void -wd.waitForFunction(() => {}, [num], num); // $ExpectType void -wd.waitForFunction(() => {}, [str], num); // $ExpectType void +expectError(wd.waitForFunction()); +expectType(wd.waitForFunction('div')); +expectType(wd.waitForFunction(() => {})); +expectType(wd.waitForFunction(() => {}, [num], num)); +expectType(wd.waitForFunction(() => {}, [str], num)); -wd.waitInUrl(); // $ExpectError -wd.waitInUrl(str); // $ExpectType void -wd.waitInUrl(str, num); // $ExpectType void +expectError(wd.waitInUrl()); +expectType(wd.waitInUrl(str)); +expectType(wd.waitInUrl(str, num)); -wd.waitForText(); // $ExpectError -wd.waitForText(str); // $ExpectType void -wd.waitForText(str, num, str); // $ExpectType void +expectError(wd.waitForText()); +expectType(wd.waitForText(str)); +expectType(wd.waitForText(str, num, str)); -wd.waitForValue(); // $ExpectError -wd.waitForValue(str); // $ExpectError -wd.waitForValue(str, str); // $ExpectType void -wd.waitForValue(str, str, num); // $ExpectType void +expectError(wd.waitForValue()); +expectError(wd.waitForValue(str)); +expectType(wd.waitForValue(str, str)); +expectType(wd.waitForValue(str, str, num)); -wd.waitNumberOfVisibleElements(); // $ExpectError -wd.waitNumberOfVisibleElements('div'); // $ExpectError -wd.waitNumberOfVisibleElements(str, num); // $ExpectType void -wd.waitNumberOfVisibleElements(str, num, num); // $ExpectType void +expectError(wd.waitNumberOfVisibleElements()); +expectError(wd.waitNumberOfVisibleElements('div')); +expectType(wd.waitNumberOfVisibleElements(str, num)); +expectType(wd.waitNumberOfVisibleElements(str, num, num)); -wd.waitUrlEquals(); // $ExpectError -wd.waitUrlEquals(str); // $ExpectType void -wd.waitUrlEquals(str, num); // $ExpectType void +expectError(wd.waitUrlEquals()); +expectType(wd.waitUrlEquals(str)); +expectType(wd.waitUrlEquals(str, num)); -wd.switchTo(); // $ExpectType void -wd.switchTo('div'); // $ExpectType void +expectType(wd.switchTo()); +expectType(wd.switchTo('div')); -wd.switchToNextTab(num, num); // $ExpectType void +expectType(wd.switchToNextTab(num, num)); -wd.switchToPreviousTab(num, num); // $ExpectType void +expectType(wd.switchToPreviousTab(num, num)); -wd.closeCurrentTab(); // $ExpectType void +expectType(wd.closeCurrentTab()); -wd.openNewTab(); // $ExpectType void +expectType(wd.openNewTab()); -wd.refreshPage(); // $ExpectType void +expectType(wd.refreshPage()); -wd.scrollPageToTop(); // $ExpectType void +expectType(wd.scrollPageToTop()); -wd.scrollPageToBottom(); // $ExpectType void +expectType(wd.scrollPageToBottom()); -wd.setGeoLocation(); // $ExpectError -wd.setGeoLocation(num); // $ExpectError -wd.setGeoLocation(num, num); // $ExpectType void -wd.setGeoLocation(num, num, num); // $ExpectType void +expectError(wd.setGeoLocation()); +expectError(wd.setGeoLocation(num)); +expectType(wd.setGeoLocation(num, num)); +expectType(wd.setGeoLocation(num, num, num)); -wd.dontSeeCookie(); // $ExpectError -wd.dontSeeCookie(str); // $ExpectType void +expectError(wd.dontSeeCookie()); +expectType(wd.dontSeeCookie(str)); -wd.dragAndDrop(); // $ExpectError -wd.dragAndDrop('#dragHandle'); // $ExpectError +expectError(wd.dragAndDrop()); +expectError(wd.dragAndDrop('#dragHandle')); wd.dragAndDrop('#dragHandle', '#container'); -wd.grabTextFromAll(); // $ExpectError -wd.grabTextFromAll('div'); // $ExpectType Promise +expectError(wd.grabTextFromAll()); +expectType>(wd.grabTextFromAll('div')); -wd.grabTextFrom(); // $ExpectError -wd.grabTextFrom('div'); // $ExpectType Promise +expectError(wd.grabTextFrom()); +expectType>(wd.grabTextFrom('div')); -wd.grabHTMLFromAll(); // $ExpectError -wd.grabHTMLFromAll('div'); // $ExpectType Promise +expectError(wd.grabHTMLFromAll()); +expectType>(wd.grabHTMLFromAll('div')); -wd.grabHTMLFrom(); // $ExpectError -wd.grabHTMLFrom('div'); // $ExpectType Promise +expectError(wd.grabHTMLFrom()); +expectType>(wd.grabHTMLFrom('div')); -wd.grabValueFromAll(); // $ExpectError -wd.grabValueFromAll('div'); // $ExpectType Promise +expectError(wd.grabValueFromAll()); +expectType>(wd.grabValueFromAll('div')); -wd.grabValueFrom(); // $ExpectError -wd.grabValueFrom('div'); // $ExpectType Promise +expectError(wd.grabValueFrom()); +expectType>(wd.grabValueFrom('div')); -wd.grabCssPropertyFromAll(); // $ExpectError -wd.grabCssPropertyFromAll('div'); // $ExpectError -wd.grabCssPropertyFromAll('div', 'color'); // $ExpectType Promise +expectError(wd.grabCssPropertyFromAll()); +expectError(wd.grabCssPropertyFromAll('div')); +expectType>(wd.grabCssPropertyFromAll('div', 'color')); -wd.grabCssPropertyFrom(); // $ExpectError -wd.grabCssPropertyFrom('div'); // $ExpectError -wd.grabCssPropertyFrom('div', 'color'); // $ExpectType Promise +expectError(wd.grabCssPropertyFrom()); +expectError(wd.grabCssPropertyFrom('div')); +expectType>(wd.grabCssPropertyFrom('div', 'color')); -wd.grabAttributeFromAll(); // $ExpectError -wd.grabAttributeFromAll('div'); // $ExpectError -wd.grabAttributeFromAll('div', 'style'); // $ExpectType Promise +expectError(wd.grabAttributeFromAll()); +expectError(wd.grabAttributeFromAll('div')); +expectType>(wd.grabAttributeFromAll('div', 'style')); -wd.grabAttributeFrom(); // $ExpectError -wd.grabAttributeFrom('div'); // $ExpectError -wd.grabAttributeFrom('div', 'style'); // $ExpectType Promise +expectError(wd.grabAttributeFrom()); +expectError(wd.grabAttributeFrom('div')); +expectType>(wd.grabAttributeFrom('div', 'style')); -wd.grabTitle(); // $ExpectType Promise +expectType>(wd.grabTitle()); -wd.grabSource(); // $ExpectType Promise +expectType>(wd.grabSource()); wd.grabBrowserLogs(); // $ExpectType Promise | undefined -wd.grabCurrentUrl(); // $ExpectType Promise +expectType>(wd.grabCurrentUrl()); -wd.grabNumberOfVisibleElements(); // $ExpectError -wd.grabNumberOfVisibleElements('div'); // $ExpectType Promise +expectError(wd.grabNumberOfVisibleElements()); +expectType>(wd.grabNumberOfVisibleElements('div')); wd.grabCookie(); // $ExpectType any wd.grabCookie('name'); // $ExpectType any -wd.grabPopupText(); // $ExpectType Promise +expectType>(wd.grabPopupText()); -wd.grabAllWindowHandles(); // $ExpectType Promise -wd.grabCurrentWindowHandle(); // $ExpectType Promise +expectType>(wd.grabAllWindowHandles()); +expectType>(wd.grabCurrentWindowHandle()); -wd.grabNumberOfOpenTabs(); // $ExpectType Promise +expectType>(wd.grabNumberOfOpenTabs()); const psp = wd.grabPageScrollPosition(); // $ExpectType Promise psp.then( @@ -465,8 +480,8 @@ psp.then( }, ); -wd.grabGeoLocation(); // $ExpectType Promise<{ latitude: number; longitude: number; altitude: number; }> +expectType>(wd.grabGeoLocation()); -wd.grabElementBoundingRect(); // $ExpectError -wd.grabElementBoundingRect('h3'); // $ExpectType Promise | Promise -wd.grabElementBoundingRect('h3', 'width'); // $ExpectType Promise | Promise +expectError(wd.grabElementBoundingRect()); +//expectType>(wd.grabElementBoundingRect('h3')); +//expectType>(wd.grabElementBoundingRect('h3', 'width'));