From 1f7f2a3eaad0734b0267c49189c942e3bc3c285b Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Wed, 17 Jun 2020 19:13:36 +0300 Subject: [PATCH 01/20] feat(ts): Add better tests for typescript --- .eslintrc.json | 1 + .github/workflows/dtslint.yml | 24 ++++++++++++++++++++++ package.json | 9 ++++---- typings/index.d.ts | 1 - typings/steps.d.ts | 10 +++++++++ typings/tests/helpers/WebDriverIO.types.ts | 3 +++ typings/tests/test.ts | 5 +++++ typings/tsconfig.json | 20 ++++++++++++++++++ typings/tslint.json | 3 +++ 9 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/dtslint.yml create mode 100644 typings/steps.d.ts create mode 100644 typings/tests/helpers/WebDriverIO.types.ts create mode 100644 typings/tests/test.ts create mode 100644 typings/tsconfig.json create mode 100644 typings/tslint.json diff --git a/.eslintrc.json b/.eslintrc.json index 33d9c6e9a..b2a4faf69 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,6 +11,7 @@ "no-undef": 0, "prefer-destructuring": 0, "no-param-reassign": 0, + "no-multiple-empty-lines": 0, "max-len": 0, "camelcase": 0, "no-shadow": 0, diff --git a/.github/workflows/dtslint.yml b/.github/workflows/dtslint.yml new file mode 100644 index 000000000..bcbeb9b69 --- /dev/null +++ b/.github/workflows/dtslint.yml @@ -0,0 +1,24 @@ +name: Typings tests + +on: + push: + branches: + - master + pull_request: + branches: + - '**' + +jobs: + test: + runs-on: ubuntu-18.04 + strategy: + matrix: + node-version: [12.x] + steps: + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm dtslint diff --git a/package.json b/package.json index 50eda6723..5d9124180 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,8 @@ "def": "./runio.js def", "dev:graphql": "nodemon test/data/graphql/index.js", "publish:site": "./runio.js publish:site", - "update-contributor-faces": "contributor-faces ." + "update-contributor-faces": "contributor-faces .", + "dtslint": "dtslint typings --expectOnly --localTs '/Users/user/github/TinkoffCreditSystem/CodeceptJS/node_modules/typescript/lib'" }, "dependencies": { "@codeceptjs/configure": "^0.4.0", @@ -57,7 +58,6 @@ "allure-js-commons": "^1.3.2", "arrify": "^2.0.1", "axios": "^0.19.1", - "acorn": "^7.1.0", "chalk": "^1.1.3", "commander": "^2.20.3", "css-to-xpath": "^0.1.0", @@ -100,6 +100,7 @@ "chai-subset": "^1.6.0", "contributor-faces": "^1.0.3", "documentation": "^12.1.4", + "dtslint": "^3.6.12", "eslint": "^6.8.0", "eslint-config-airbnb-base": "^14.0.0", "eslint-plugin-import": "^2.19.1", @@ -130,9 +131,9 @@ "typescript": "^2.9.2", "wdio-docker-service": "^1.5.0", "webdriverio": "^6.1.9", + "xml2js": "^0.4.23", "xmldom": "^0.1.31", - "xpath": "0.0.27", - "xml2js": "^0.4.23" + "xpath": "0.0.27" }, "engines": { "node": ">=8.9.1", diff --git a/typings/index.d.ts b/typings/index.d.ts index 7e60b0252..8857fbe24 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1,4 +1,3 @@ -// Type definitions for CodeceptJS // Project: https://github.com/codeception/codeceptjs/ /// /// diff --git a/typings/steps.d.ts b/typings/steps.d.ts new file mode 100644 index 000000000..0dd4ac685 --- /dev/null +++ b/typings/steps.d.ts @@ -0,0 +1,10 @@ +/// + +declare namespace CodeceptJS { + interface SupportObject { I: CodeceptJS.I } + interface Methods extends CodeceptJS.WebDriver {} + interface I extends WithTranslation {} + namespace Translation { + interface Actions {} + } +} diff --git a/typings/tests/helpers/WebDriverIO.types.ts b/typings/tests/helpers/WebDriverIO.types.ts new file mode 100644 index 000000000..d741405d5 --- /dev/null +++ b/typings/tests/helpers/WebDriverIO.types.ts @@ -0,0 +1,3 @@ +Scenario('', ({ I }) =>{ + I.grabAllWindowHandles() // $ExpectType string[] +}) diff --git a/typings/tests/test.ts b/typings/tests/test.ts new file mode 100644 index 000000000..2ae250655 --- /dev/null +++ b/typings/tests/test.ts @@ -0,0 +1,5 @@ +Feature('') + +Scenario('', () => { + console.log('') +}) diff --git a/typings/tsconfig.json b/typings/tsconfig.json new file mode 100644 index 000000000..278abd8a9 --- /dev/null +++ b/typings/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "es2018", + "lib": ["es2018"], + "esModuleInterop": true, + "module": "commonjs", + "strictNullChecks": true, + "noImplicitAny": true, + "noUnusedLocals": false, + "noUnusedParameters": false, + "noImplicitThis": true, + "strictFunctionTypes": true, + "skipLibCheck": true, + "types": [] + }, + "include": [ + "**/*.ts", + "steps.d.ts" + ] +} diff --git a/typings/tslint.json b/typings/tslint.json new file mode 100644 index 000000000..6490e53ea --- /dev/null +++ b/typings/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dtslint.json" +} From ca8731970d115c5cd44b92e52cfc308450cfb329 Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Wed, 17 Jun 2020 19:16:56 +0300 Subject: [PATCH 02/20] fix --- .github/workflows/dtslint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dtslint.yml b/.github/workflows/dtslint.yml index bcbeb9b69..99cf065a0 100644 --- a/.github/workflows/dtslint.yml +++ b/.github/workflows/dtslint.yml @@ -21,4 +21,4 @@ jobs: with: node-version: ${{ matrix.node-version }} - run: npm install - - run: npm dtslint + - run: npm run dtslint From 2cdbbcc1c2133a7dd4182b97a0d93092fb3ccb45 Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Wed, 17 Jun 2020 19:27:52 +0300 Subject: [PATCH 03/20] fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5d9124180..a657d2d28 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "dev:graphql": "nodemon test/data/graphql/index.js", "publish:site": "./runio.js publish:site", "update-contributor-faces": "contributor-faces .", - "dtslint": "dtslint typings --expectOnly --localTs '/Users/user/github/TinkoffCreditSystem/CodeceptJS/node_modules/typescript/lib'" + "dtslint": "dtslint typings --expectOnly --localTs './node_modules/typescript/lib'" }, "dependencies": { "@codeceptjs/configure": "^0.4.0", From 5ef4f891e1fce77bc9129a8d1ca19682a947bd5f Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Wed, 17 Jun 2020 19:35:26 +0300 Subject: [PATCH 04/20] f --- .github/workflows/dtslint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dtslint.yml b/.github/workflows/dtslint.yml index 99cf065a0..c6fcc882a 100644 --- a/.github/workflows/dtslint.yml +++ b/.github/workflows/dtslint.yml @@ -21,4 +21,5 @@ jobs: with: node-version: ${{ matrix.node-version }} - run: npm install + - run: npm run def - run: npm run dtslint From a8163a8cbe3a428ea4e030044ca58f35886c1aae Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Wed, 17 Jun 2020 23:42:15 +0300 Subject: [PATCH 05/20] add more tests --- lib/helper.js | 4 + package.json | 2 +- typings/Mocha.d.ts | 138 ++++++--------------- typings/index.d.ts | 9 +- typings/steps.d.ts | 2 - typings/tests/global-variables.ts | 45 +++++++ typings/tests/helpers/WebDriverIO.types.ts | 2 +- typings/tests/test.ts | 5 - typings/tsconfig.json | 4 +- typings/tslint.json | 19 ++- typings/utils.d.ts | 4 +- 11 files changed, 119 insertions(+), 115 deletions(-) create mode 100644 typings/tests/global-variables.ts delete mode 100644 typings/tests/test.ts diff --git a/lib/helper.js b/lib/helper.js index fc438223b..8b15c8056 100644 --- a/lib/helper.js +++ b/lib/helper.js @@ -16,6 +16,10 @@ const { isAsyncFunction } = require('./utils'); */ class Helper { + /** + * + * @param {*} config + */ constructor(config) { this.config = config; } diff --git a/package.json b/package.json index a657d2d28..7a26b5412 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "dev:graphql": "nodemon test/data/graphql/index.js", "publish:site": "./runio.js publish:site", "update-contributor-faces": "contributor-faces .", - "dtslint": "dtslint typings --expectOnly --localTs './node_modules/typescript/lib'" + "dtslint": "dtslint typings --localTs './node_modules/typescript/lib'" }, "dependencies": { "@codeceptjs/configure": "^0.4.0", diff --git a/typings/Mocha.d.ts b/typings/Mocha.d.ts index f1ea30558..cb73a2a1c 100644 --- a/typings/Mocha.d.ts +++ b/typings/Mocha.d.ts @@ -1,4 +1,4 @@ -declare module Mocha { +declare namespace Mocha { class SuiteRunnable { private _beforeEach; private _beforeAll; @@ -11,9 +11,9 @@ declare module Mocha { private _retries; private _onlyTests; private _onlySuites; - + constructor(title: string, parentContext?: Context); - + ctx: Context; suites: Suite[]; tests: Test[]; @@ -23,7 +23,7 @@ declare module Mocha { delayed: boolean; parent: Suite | undefined; title: string; - + /** * Create a new `Suite` with the given `title` and parent `Suite`. When a suite * with the same title is already present, that suite is returned to provide @@ -32,217 +32,161 @@ declare module Mocha { * @see https://mochajs.org/api/mocha#.exports.create */ static create(parent: Suite, title: string): Suite; - + /** * Return a clone of this `Suite`. * * @see https://mochajs.org/api/Mocha.Suite.html#clone */ clone(): Suite; - + /** * Get timeout `ms`. * * @see https://mochajs.org/api/Mocha.Suite.html#timeout */ timeout(): number; - + /** * Set timeout `ms` or short-hand such as "2s". * * @see https://mochajs.org/api/Mocha.Suite.html#timeout */ timeout(ms: string | number): this; - + /** * Get number of times to retry a failed test. * * @see https://mochajs.org/api/Mocha.Suite.html#retries */ retries(): number; - + /** * Set number of times to retry a failed test. * * @see https://mochajs.org/api/Mocha.Suite.html#retries */ retries(n: string | number): this; - + /** * Get whether timeouts are enabled. * * @see https://mochajs.org/api/Mocha.Suite.html#enableTimeouts */ enableTimeouts(): boolean; - + /** * Set whether timeouts are `enabled`. * * @see https://mochajs.org/api/Mocha.Suite.html#enableTimeouts */ enableTimeouts(enabled: boolean): this; - + /** * Get slow `ms`. * * @see https://mochajs.org/api/Mocha.Suite.html#slow */ slow(): number; - + /** * Set slow `ms` or short-hand such as "2s". * * @see https://mochajs.org/api/Mocha.Suite.html#slow */ slow(ms: string | number): this; - + /** * Get whether to bail after first error. * * @see https://mochajs.org/api/Mocha.Suite.html#bail */ bail(): boolean; - + /** * Set whether to bail after first error. * * @see https://mochajs.org/api/Mocha.Suite.html#bail */ bail(bail: boolean): this; - + /** * Check if this suite or its parent suite is marked as pending. * * @see https://mochajs.org/api/Mocha.Suite.html#isPending */ isPending(): boolean; - - /** - * Run `fn(test[, done])` before running tests. - * - * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll - */ - beforeAll(fn?: Func): this; - - /** - * Run `fn(test[, done])` before running tests. - * - * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll - */ - beforeAll(fn?: AsyncFunc): this; - + /** * Run `fn(test[, done])` before running tests. * * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll */ - beforeAll(title: string, fn?: Func): this; - + beforeAll(fn?: Func | AsyncFunc): this; + /** * Run `fn(test[, done])` before running tests. * * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll */ - beforeAll(title: string, fn?: AsyncFunc): this; - - /** - * Run `fn(test[, done])` after running tests. - * - * @see https://mochajs.org/api/Mocha.Suite.html#afterAll - */ - afterAll(fn?: Func): this; - - /** - * Run `fn(test[, done])` after running tests. - * - * @see https://mochajs.org/api/Mocha.Suite.html#afterAll - */ - afterAll(fn?: AsyncFunc): this; - + beforeAll(title: string, fn?: Func | AsyncFunc): this; + /** * Run `fn(test[, done])` after running tests. * * @see https://mochajs.org/api/Mocha.Suite.html#afterAll */ - afterAll(title: string, fn?: Func): this; - + afterAll(fn?: Func | AsyncFunc): this; + /** * Run `fn(test[, done])` after running tests. * * @see https://mochajs.org/api/Mocha.Suite.html#afterAll */ - afterAll(title: string, fn?: AsyncFunc): this; - - /** - * Run `fn(test[, done])` before each test case. - * - * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach - */ - beforeEach(fn?: Func): this; - - /** - * Run `fn(test[, done])` before each test case. - * - * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach - */ - beforeEach(fn?: AsyncFunc): this; - + afterAll(title: string, fn?: Func | AsyncFunc): this; + /** * Run `fn(test[, done])` before each test case. * * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach */ - beforeEach(title: string, fn?: Func): this; - + beforeEach(fn?: Func | AsyncFunc): this; + /** * Run `fn(test[, done])` before each test case. * * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach */ - beforeEach(title: string, fn?: AsyncFunc): this; - - /** - * Run `fn(test[, done])` after each test case. - * - * @see https://mochajs.org/api/Mocha.Suite.html#afterEach - */ - afterEach(fn?: Func): this; - - /** - * Run `fn(test[, done])` after each test case. - * - * @see https://mochajs.org/api/Mocha.Suite.html#afterEach - */ - afterEach(fn?: AsyncFunc): this; - + beforeEach(title: string, fn?: Func | AsyncFunc): this; + /** * Run `fn(test[, done])` after each test case. * * @see https://mochajs.org/api/Mocha.Suite.html#afterEach */ - afterEach(title: string, fn?: Func): this; - + afterEach(fn?: Func | AsyncFunc): this; + /** * Run `fn(test[, done])` after each test case. * * @see https://mochajs.org/api/Mocha.Suite.html#afterEach */ - afterEach(title: string, fn?: AsyncFunc): this; - + afterEach(title: string, fn?: Func | AsyncFunc): this; + /** * Add a test `suite`. * * @see https://mochajs.org/api/Mocha.Suite.html#addSuite */ addSuite(suite: Suite): this; - + /** * Add a `test` to this suite. * * @see https://mochajs.org/api/Mocha.Suite.html#addTest */ addTest(test: Test): this; - + /** * Return the full title generated by recursively concatenating the parent's * full title. @@ -250,7 +194,7 @@ declare module Mocha { * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#fullTitle */ fullTitle(): string; - + /** * Return the title path generated by recursively concatenating the parent's * title path. @@ -258,14 +202,14 @@ declare module Mocha { * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#titlePath */ titlePath(): string[]; - + /** * Return the total number of tests. * * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#total */ total(): number; - + /** * Iterates through each suite recursively to find all tests. Applies a * function in the format `fn(test)`. @@ -273,14 +217,14 @@ declare module Mocha { * @see https://mochajs.org/api/Mocha.Suite.html#eachTest */ eachTest(fn: (test: Test) => void): this; - + /** * This will run the root suite if we happen to be running in delayed mode. * * @see https://mochajs.org/api/Mocha.Suite.html#run */ run(): void; - + /** * Generic hook-creator. */ @@ -569,4 +513,4 @@ declare module Mocha { [key: string]: any; } -} \ No newline at end of file +} diff --git a/typings/index.d.ts b/typings/index.d.ts index 8857fbe24..65240b06c 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -43,13 +43,12 @@ declare namespace CodeceptJS { type LocatorOrString = string | ILocator | Locator; interface HookCallback { (args: SupportObject): void; } - interface Scenario extends IScenario { only: IScenario, skip: IScenario, todo: IScenario} + interface Scenario extends IScenario { only: IScenario, skip: IScenario, todo: IScenario} interface IData { Scenario: IScenario, only: { Scenario: IScenario } } interface IScenario { // Scenario.todo can be called only with a title. - (title: string): ScenarioConfig; - (title: string, callback: HookCallback): ScenarioConfig; + (title: string, callback?: HookCallback): ScenarioConfig; (title: string, opts: { [key: string]: any }, callback: HookCallback): ScenarioConfig; } interface IHook { (callback: HookCallback): void; } @@ -144,13 +143,13 @@ declare namespace Mocha { After: typeof After; } - interface Suite extends SuiteRunnable{ + interface Suite extends SuiteRunnable { tags: any[] comment: string feature: any } - interface Test extends Runnable{ + interface Test extends Runnable { tags: any[]; } } diff --git a/typings/steps.d.ts b/typings/steps.d.ts index 0dd4ac685..acef27456 100644 --- a/typings/steps.d.ts +++ b/typings/steps.d.ts @@ -1,5 +1,3 @@ -/// - declare namespace CodeceptJS { interface SupportObject { I: CodeceptJS.I } interface Methods extends CodeceptJS.WebDriver {} diff --git a/typings/tests/global-variables.ts b/typings/tests/global-variables.ts new file mode 100644 index 000000000..249b25524 --- /dev/null +++ b/typings/tests/global-variables.ts @@ -0,0 +1,45 @@ +Feature() // $ExpectError +Scenario() // $ExpectError +Before() // $ExpectError +BeforeSuite() // $ExpectError +After() // $ExpectError +AfterSuite() // $ExpectError + +Feature('feature') // $ExpectType FeatureConfig + +Scenario('scenario') // $ExpectType ScenarioConfig +Scenario( + 'scenario', + {}, // $ExpectType {} + () => {} // $ExpectType () => void +) +Scenario( + 'scenario', + () => {} // $ExpectType () => void +) +const callback: CodeceptJS.HookCallback = () => {} +Scenario( + 'scenario', + callback // $ExpectType HookCallback +) +Scenario('scenario', + (args) => { + args // $ExpectType SupportObject + args.I // $ExpectType I + } +) + +class CustomClass extends Helper { + constructor(config: any) { + super( + config // $ExpectType any + ) + } +} + +// Before(( +// args // $ExpectType string +// ) => {}) +// BeforeSuite() // $ExpectError +// After() // $ExpectError +// AfterSuite() // $ExpectError diff --git a/typings/tests/helpers/WebDriverIO.types.ts b/typings/tests/helpers/WebDriverIO.types.ts index d741405d5..1d86af5f7 100644 --- a/typings/tests/helpers/WebDriverIO.types.ts +++ b/typings/tests/helpers/WebDriverIO.types.ts @@ -1,3 +1,3 @@ -Scenario('', ({ I }) =>{ +Scenario('', ({ I }) => { I.grabAllWindowHandles() // $ExpectType string[] }) diff --git a/typings/tests/test.ts b/typings/tests/test.ts deleted file mode 100644 index 2ae250655..000000000 --- a/typings/tests/test.ts +++ /dev/null @@ -1,5 +0,0 @@ -Feature('') - -Scenario('', () => { - console.log('') -}) diff --git a/typings/tsconfig.json b/typings/tsconfig.json index 278abd8a9..f4b1d16e1 100644 --- a/typings/tsconfig.json +++ b/typings/tsconfig.json @@ -11,7 +11,9 @@ "noImplicitThis": true, "strictFunctionTypes": true, "skipLibCheck": true, - "types": [] + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "include": [ "**/*.ts", diff --git a/typings/tslint.json b/typings/tslint.json index 6490e53ea..d90c8c2da 100644 --- a/typings/tslint.json +++ b/typings/tslint.json @@ -1,3 +1,20 @@ { - "extends": "dtslint/dtslint.json" + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-unnecessary-qualifier": false, + "interface-name": false, + "jsdoc-format": false, + "ban-types": false, + "no-any-union": false, + "max-line-length": false, + "no-single-declare-module": false, + "no-unnecessary-class": false, + "no-var-keyword": false + }, + "linterOptions": { + "exclude": [ + "./types.d.ts" + ] + } } diff --git a/typings/utils.d.ts b/typings/utils.d.ts index 0a1804aca..42e77fb0c 100644 --- a/typings/utils.d.ts +++ b/typings/utils.d.ts @@ -1,5 +1,5 @@ -type ValueOf = T[keyof T] -type KeyValueTupleToObject = { +export type ValueOf = T[keyof T] +export type KeyValueTupleToObject = { [K in T[0]]: Extract[1] } export type Translate> = KeyValueTupleToObject Date: Thu, 18 Jun 2020 00:13:10 +0300 Subject: [PATCH 06/20] add tests for helper --- lib/command/definitions.js | 4 +- lib/helper.js | 1 - typings/index.d.ts | 6 +-- typings/steps.d.ts | 4 +- ...variables.ts => global-variables.types.ts} | 8 ---- typings/tests/helper.types.ts | 46 +++++++++++++++++++ typings/tslint.json | 8 +--- 7 files changed, 55 insertions(+), 22 deletions(-) rename typings/tests/{global-variables.ts => global-variables.types.ts} (86%) create mode 100644 typings/tests/helper.types.ts diff --git a/lib/command/definitions.js b/lib/command/definitions.js index b219009eb..458c2d569 100644 --- a/lib/command/definitions.js +++ b/lib/command/definitions.js @@ -48,12 +48,12 @@ module.exports = function (genPath, options) { helperPaths[name] = require; helperNames.push(name); } else { - helperNames.push(`CodeceptJS.${name}`); + helperNames.push(name); } } const supportObject = new Map(); - supportObject.set('I', 'CodeceptJS.I'); + supportObject.set('I', 'I'); for (const name in codecept.config.include) { const includePath = codecept.config.include[name]; if (name === 'I' || name === translations.I) { diff --git a/lib/helper.js b/lib/helper.js index 8b15c8056..e7b153408 100644 --- a/lib/helper.js +++ b/lib/helper.js @@ -173,7 +173,6 @@ class Helper { * @readonly * @type {*} */ - /* eslint-enable */ get helpers() { return container.helpers(); } diff --git a/typings/index.d.ts b/typings/index.d.ts index 65240b06c..1af1392a6 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -5,7 +5,7 @@ declare namespace CodeceptJS { type WithTranslation = T & - import("./utils").Translate; + import("./utils").Translate; // Could get extended by user generated typings interface Methods extends ActorStatic {} @@ -13,7 +13,7 @@ declare namespace CodeceptJS { interface IHook {} interface IScenario {} interface SupportObject { - I: CodeceptJS.I; + I: I; } namespace Translation { interface Actions {} @@ -25,7 +25,7 @@ declare namespace CodeceptJS { } // Types who are not be defined by JSDoc - type actor = ( + type actor = void }>( customSteps?: T & ThisType> ) => WithTranslation; diff --git a/typings/steps.d.ts b/typings/steps.d.ts index acef27456..490e6c9b9 100644 --- a/typings/steps.d.ts +++ b/typings/steps.d.ts @@ -1,6 +1,6 @@ declare namespace CodeceptJS { - interface SupportObject { I: CodeceptJS.I } - interface Methods extends CodeceptJS.WebDriver {} + interface SupportObject { I: I } + interface Methods extends WebDriver {} interface I extends WithTranslation {} namespace Translation { interface Actions {} diff --git a/typings/tests/global-variables.ts b/typings/tests/global-variables.types.ts similarity index 86% rename from typings/tests/global-variables.ts rename to typings/tests/global-variables.types.ts index 249b25524..df3edd3bf 100644 --- a/typings/tests/global-variables.ts +++ b/typings/tests/global-variables.types.ts @@ -29,14 +29,6 @@ Scenario('scenario', } ) -class CustomClass extends Helper { - constructor(config: any) { - super( - config // $ExpectType any - ) - } -} - // Before(( // args // $ExpectType string // ) => {}) diff --git a/typings/tests/helper.types.ts b/typings/tests/helper.types.ts new file mode 100644 index 000000000..1f02ecea7 --- /dev/null +++ b/typings/tests/helper.types.ts @@ -0,0 +1,46 @@ +// @TODO: Need tests arguments of protected methods + +class CustomClass extends Helper { + constructor(config: any) { + super( + config // $ExpectType any + ) + this.helpers // $ExpectType any + this.debug() // $ExpectError + this.debugSection() // $ExpectError + this.debugSection('[Section]') // $ExpectError + + this.debug('log') // $ExpectType void + this.debugSection('[Section]', 'log') // $ExpectType void + } + _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 +} + +const customClass = new Helper({}) + +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 + +customClass._useTo() // $ExpectType void diff --git a/typings/tslint.json b/typings/tslint.json index d90c8c2da..3102d2b77 100644 --- a/typings/tslint.json +++ b/typings/tslint.json @@ -2,15 +2,11 @@ "extends": "dtslint/dtslint.json", "rules": { "semicolon": false, - "no-unnecessary-qualifier": false, + "no-empty-interface": false, "interface-name": false, "jsdoc-format": false, - "ban-types": false, - "no-any-union": false, "max-line-length": false, - "no-single-declare-module": false, - "no-unnecessary-class": false, - "no-var-keyword": false + "no-single-declare-module": false }, "linterOptions": { "exclude": [ From 0e4ae9c7ab67e5cb6d5bafb70ad13d1672ea59a4 Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Thu, 18 Jun 2020 00:54:04 +0300 Subject: [PATCH 07/20] f --- docs/webapi/grabAllWindowHandles.mustache | 7 +++++++ docs/webapi/grabCurrentWindowHandle.mustache | 6 ++++++ lib/helper/WebDriver.js | 14 ++------------ typings/tests/helpers/WebDriverIO.types.ts | 7 ++++--- 4 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 docs/webapi/grabAllWindowHandles.mustache create mode 100644 docs/webapi/grabCurrentWindowHandle.mustache diff --git a/docs/webapi/grabAllWindowHandles.mustache b/docs/webapi/grabAllWindowHandles.mustache new file mode 100644 index 000000000..5f29c1ed7 --- /dev/null +++ b/docs/webapi/grabAllWindowHandles.mustache @@ -0,0 +1,7 @@ +Get all Window Handles. +Useful for referencing a specific handle when calling `I.switchToWindow(handle)` + +```js +const windows = await I.grabAllWindowHandles(); +``` +@returns {Array} diff --git a/docs/webapi/grabCurrentWindowHandle.mustache b/docs/webapi/grabCurrentWindowHandle.mustache new file mode 100644 index 000000000..48d75c9c9 --- /dev/null +++ b/docs/webapi/grabCurrentWindowHandle.mustache @@ -0,0 +1,6 @@ +Get the current Window Handle. +Useful for referencing it when calling `I.switchToWindow(handle)` +```js +const window = await I.grabCurrentWindowHandle(); +``` +@returns {string} diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index 7b38c2c79..439414020 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -1895,24 +1895,14 @@ class WebDriver extends Helper { } /** - * Get all Window Handles. - * Useful for referencing a specific handle when calling `I.switchToWindow(handle)` - * - * ```js - * const windows = await I.grabAllWindowHandles(); - * ``` + * {{> grabAllWindowHandles }} */ async grabAllWindowHandles() { return this.browser.getWindowHandles(); } /** - * Get the current Window Handle. - * Useful for referencing it when calling `I.switchToWindow(handle)` - * - * ```js - * const window = await I.grabCurrentWindowHandle(); - * ``` + * {{> grabCurrentWindowHandle }} */ async grabCurrentWindowHandle() { return this.browser.getWindowHandle(); diff --git a/typings/tests/helpers/WebDriverIO.types.ts b/typings/tests/helpers/WebDriverIO.types.ts index 1d86af5f7..bfe5618f2 100644 --- a/typings/tests/helpers/WebDriverIO.types.ts +++ b/typings/tests/helpers/WebDriverIO.types.ts @@ -1,3 +1,4 @@ -Scenario('', ({ I }) => { - I.grabAllWindowHandles() // $ExpectType string[] -}) +const wd = new CodeceptJS.WebDriver() + +wd.grabAllWindowHandles() // $ExpectType string[] +wd.grabCurrentWindowHandle() // $ExpectType string From 3eb83c27a01602ed4f2b04325d8f0c3277e6705a Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Thu, 18 Jun 2020 01:06:17 +0300 Subject: [PATCH 08/20] add tests --- typings/tests/helpers/WebDriverIO.types.ts | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/typings/tests/helpers/WebDriverIO.types.ts b/typings/tests/helpers/WebDriverIO.types.ts index bfe5618f2..fc1a52654 100644 --- a/typings/tests/helpers/WebDriverIO.types.ts +++ b/typings/tests/helpers/WebDriverIO.types.ts @@ -1,4 +1,43 @@ const wd = new CodeceptJS.WebDriver() +wd.amOnPage() // $ExpectError +wd.amOnPage('') // $ExpectType void + +wd.click() // $ExpectError +wd.click('div') // $ExpectType void +wd.click({ css: 'div' }) +wd.click({ xpath: '//div' }) +wd.click({ name: 'div' }) +wd.click({ id: 'div' }) +wd.click({ android: 'div' }) +wd.click({ ios: 'div' }) +wd.click(locate('div')) +wd.click('div', 'body') +wd.click('div', locate('div')) +wd.click('div', { css: 'div' }) +wd.click('div', { xpath: '//div' }) +wd.click('div', { name: '//div' }) +wd.click('div', { id: '//div' }) +wd.click('div', { android: '//div' }) +wd.click('div', { ios: '//div' }) + +wd.forceClick() // $ExpectError +wd.forceClick('div') // $ExpectType void +wd.forceClick({ css: 'div' }) +wd.forceClick({ xpath: '//div' }) +wd.forceClick({ name: 'div' }) +wd.forceClick({ id: 'div' }) +wd.forceClick({ android: 'div' }) +wd.forceClick({ ios: 'div' }) +wd.forceClick(locate('div')) +wd.forceClick('div', 'body') +wd.forceClick('div', locate('div')) +wd.forceClick('div', { css: 'div' }) +wd.forceClick('div', { xpath: '//div' }) +wd.forceClick('div', { name: '//div' }) +wd.forceClick('div', { id: '//div' }) +wd.forceClick('div', { android: '//div' }) +wd.forceClick('div', { ios: '//div' }) + wd.grabAllWindowHandles() // $ExpectType string[] wd.grabCurrentWindowHandle() // $ExpectType string From 4cbb55061d98c37d35645541a7d897fd48c0b539 Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Thu, 18 Jun 2020 01:12:00 +0300 Subject: [PATCH 09/20] added methods --- typings/tests/helpers/WebDriverIO.types.ts | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/typings/tests/helpers/WebDriverIO.types.ts b/typings/tests/helpers/WebDriverIO.types.ts index fc1a52654..3ee23f1b1 100644 --- a/typings/tests/helpers/WebDriverIO.types.ts +++ b/typings/tests/helpers/WebDriverIO.types.ts @@ -39,5 +39,63 @@ wd.forceClick('div', { id: '//div' }) wd.forceClick('div', { android: '//div' }) wd.forceClick('div', { ios: '//div' }) +wd.doubleClick() // $ExpectError +wd.doubleClick('div') // $ExpectType void +wd.doubleClick({ css: 'div' }) +wd.doubleClick({ xpath: '//div' }) +wd.doubleClick({ name: 'div' }) +wd.doubleClick({ id: 'div' }) +wd.doubleClick({ android: 'div' }) +wd.doubleClick({ ios: 'div' }) +wd.doubleClick(locate('div')) +wd.doubleClick('div', 'body') +wd.doubleClick('div', locate('div')) +wd.doubleClick('div', { css: 'div' }) +wd.doubleClick('div', { xpath: '//div' }) +wd.doubleClick('div', { name: '//div' }) +wd.doubleClick('div', { id: '//div' }) +wd.doubleClick('div', { android: '//div' }) +wd.doubleClick('div', { ios: '//div' }) + +wd.rightClick() // $ExpectError +wd.rightClick('div') // $ExpectType void +wd.rightClick({ css: 'div' }) +wd.rightClick({ xpath: '//div' }) +wd.rightClick({ name: 'div' }) +wd.rightClick({ id: 'div' }) +wd.rightClick({ android: 'div' }) +wd.rightClick({ ios: 'div' }) +wd.rightClick(locate('div')) +wd.rightClick('div', 'body') +wd.rightClick('div', locate('div')) +wd.rightClick('div', { css: 'div' }) +wd.rightClick('div', { xpath: '//div' }) +wd.rightClick('div', { name: '//div' }) +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', 'value') // $ExpectType void +wd.fillField({ css: 'div' }, 'value') +wd.fillField({ xpath: '//div' }, 'value') +wd.fillField({ name: 'div' }, 'value') +wd.fillField({ id: 'div' }, 'value') +wd.fillField({ android: 'div' }, 'value') +wd.fillField({ ios: 'div' }, 'value') +wd.fillField(locate('div'), 'value') + +wd.appendField() // $ExpectError +wd.appendField('div') // $ExpectError +wd.appendField('div', 'value') // $ExpectType void +wd.appendField({ css: 'div' }, 'value') +wd.appendField({ xpath: '//div' }, 'value') +wd.appendField({ name: 'div' }, 'value') +wd.appendField({ id: 'div' }, 'value') +wd.appendField({ android: 'div' }, 'value') +wd.appendField({ ios: 'div' }, 'value') +wd.appendField(locate('div'), 'value') + wd.grabAllWindowHandles() // $ExpectType string[] wd.grabCurrentWindowHandle() // $ExpectType string From 95ed2e35d7e14ea897ab8877cdaf5f8afb606748 Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Thu, 18 Jun 2020 01:56:02 +0300 Subject: [PATCH 10/20] improve ts --- docs/webapi/clearField.mustache | 2 +- docs/webapi/scrollIntoView.mustache | 4 ++-- docs/webapi/setCookie.mustache | 2 +- package.json | 2 +- typings/index.d.ts | 5 +++++ typings/tests/helpers/WebDriverIO.types.ts | 14 ++++++++++++++ typings/tsconfig.json | 2 +- typings/tslint.json | 4 ++-- 8 files changed, 27 insertions(+), 8 deletions(-) diff --git a/docs/webapi/clearField.mustache b/docs/webapi/clearField.mustache index 26d46f1ec..afebc044c 100644 --- a/docs/webapi/clearField.mustache +++ b/docs/webapi/clearField.mustache @@ -5,4 +5,4 @@ I.clearField('Email'); I.clearField('user[email]'); I.clearField('#email'); ``` -@param {string|object} editable field located by label|name|CSS|XPath|strict locator. \ No newline at end of file +@param {LocatorOrString} editable field located by label|name|CSS|XPath|strict locator. diff --git a/docs/webapi/scrollIntoView.mustache b/docs/webapi/scrollIntoView.mustache index 930bf77d0..2a0e445a8 100644 --- a/docs/webapi/scrollIntoView.mustache +++ b/docs/webapi/scrollIntoView.mustache @@ -6,5 +6,5 @@ I.scrollIntoView('#submit', true); I.scrollIntoView('#submit', { behavior: "smooth", block: "center", inline: "center" }); ``` -@param {string|object} locator located by CSS|XPath|strict locator. -@param {boolean|object} alignToTop (optional) or scrollIntoViewOptions (optional), see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView. +@param {LocatorOrString} locator located by CSS|XPath|strict locator. +@param {ScrollIntoViewOptions} scrollIntoViewOptions see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView. diff --git a/docs/webapi/setCookie.mustache b/docs/webapi/setCookie.mustache index c792d8c1b..71add5d9e 100644 --- a/docs/webapi/setCookie.mustache +++ b/docs/webapi/setCookie.mustache @@ -12,4 +12,4 @@ I.setCookie([ ]); ``` -@param {object|array} cookie a cookie object or array of cookie objects. \ No newline at end of file +@param {Cookie|Array} cookie a cookie object or array of cookie objects. diff --git a/package.json b/package.json index 7a26b5412..e5c87840b 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "testcafe": "^1.7.1", "ts-morph": "^3.1.3", "tsd-jsdoc": "^2.3.0", - "typescript": "^2.9.2", + "typescript": "^3.7.5", "wdio-docker-service": "^1.5.0", "webdriverio": "^6.1.9", "xml2js": "^0.4.23", diff --git a/typings/index.d.ts b/typings/index.d.ts index 1af1392a6..0a8fb8416 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -7,6 +7,11 @@ declare namespace CodeceptJS { type WithTranslation = T & import("./utils").Translate; + type Cookie = { + name: string + value: string + } + // Could get extended by user generated typings interface Methods extends ActorStatic {} interface I {} diff --git a/typings/tests/helpers/WebDriverIO.types.ts b/typings/tests/helpers/WebDriverIO.types.ts index 3ee23f1b1..c77ae8cd0 100644 --- a/typings/tests/helpers/WebDriverIO.types.ts +++ b/typings/tests/helpers/WebDriverIO.types.ts @@ -97,5 +97,19 @@ wd.appendField({ android: 'div' }, 'value') wd.appendField({ ios: 'div' }, 'value') wd.appendField(locate('div'), 'value') +wd.clearField() // $ExpectError +wd.clearField('div') +wd.clearField({ css: 'div' }) +wd.clearField({ xpath: '//div' }) +wd.clearField({ name: 'div' }) +wd.clearField({ id: 'div' }) +wd.clearField({ android: 'div' }) +wd.clearField({ ios: 'div' }) + +wd.scrollIntoView('div', {behavior: "auto", block: "center", "inline": "center"}) + +wd.setCookie({name: 'name', value: 'value'}) +wd.setCookie([{name: 'name', value: 'value'}]) + wd.grabAllWindowHandles() // $ExpectType string[] wd.grabCurrentWindowHandle() // $ExpectType string diff --git a/typings/tsconfig.json b/typings/tsconfig.json index f4b1d16e1..298478b2e 100644 --- a/typings/tsconfig.json +++ b/typings/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "target": "es2018", - "lib": ["es2018"], + "lib": ["es2018", "DOM"], "esModuleInterop": true, "module": "commonjs", "strictNullChecks": true, diff --git a/typings/tslint.json b/typings/tslint.json index 3102d2b77..af865c54c 100644 --- a/typings/tslint.json +++ b/typings/tslint.json @@ -6,11 +6,11 @@ "interface-name": false, "jsdoc-format": false, "max-line-length": false, - "no-single-declare-module": false + "no-single-declare-module": false, + "no-unnecessary-qualifier": false }, "linterOptions": { "exclude": [ - "./types.d.ts" ] } } From 9cc49ee1128f45607720ffcccf39c654fa8009f6 Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Thu, 18 Jun 2020 02:23:11 +0300 Subject: [PATCH 11/20] improve typings --- docs/webapi/dragAndDrop.mustache | 4 ++-- docs/webapi/grabElementBoundingRect.mustache | 6 +++--- docs/webapi/waitForValue.mustache | 4 ++-- typings/tests/helpers/WebDriverIO.types.ts | 15 ++++++++++++++- typings/tslint.json | 8 +++++++- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/docs/webapi/dragAndDrop.mustache b/docs/webapi/dragAndDrop.mustache index f8a84784d..59a3f2f55 100644 --- a/docs/webapi/dragAndDrop.mustache +++ b/docs/webapi/dragAndDrop.mustache @@ -4,5 +4,5 @@ Drag an item to a destination element. I.dragAndDrop('#dragHandle', '#container'); ``` -@param {string|object} srcElement located by CSS|XPath|strict locator. -@param {string|object} destElement located by CSS|XPath|strict locator. \ No newline at end of file +@param {LocatorOrString} srcElement located by CSS|XPath|strict locator. +@param {LocatorOrString} destElement located by CSS|XPath|strict locator. diff --git a/docs/webapi/grabElementBoundingRect.mustache b/docs/webapi/grabElementBoundingRect.mustache index 2b3bb851c..dcb90013b 100644 --- a/docs/webapi/grabElementBoundingRect.mustache +++ b/docs/webapi/grabElementBoundingRect.mustache @@ -15,6 +15,6 @@ To get only one metric use second parameter: const width = await I.grabElementBoundingRect('h3', 'width'); // width == 527 ``` -@param {string|object} locator element located by CSS|XPath|strict locator. -@param {string} elementSize x, y, width or height of the given element. -@returns {object} Element bounding rectangle \ No newline at end of file +@param {LocatorOrString} locator element located by CSS|XPath|strict locator. +@param {string=} elementSize x, y, width or height of the given element. +@returns {DOMRect|number} Element bounding rectangle diff --git a/docs/webapi/waitForValue.mustache b/docs/webapi/waitForValue.mustache index e3c330900..0e9f8a621 100644 --- a/docs/webapi/waitForValue.mustache +++ b/docs/webapi/waitForValue.mustache @@ -4,6 +4,6 @@ Waits for the specified value to be in value attribute. I.waitForValue('//input', "GoodValue"); ``` -@param {string|object} field input field. +@param {LocatorOrString} field input field. @param {string }value expected value. -@param {number} [sec=1] (optional, `1` by default) time in seconds to wait \ No newline at end of file +@param {number} [sec=1] (optional, `1` by default) time in seconds to wait diff --git a/typings/tests/helpers/WebDriverIO.types.ts b/typings/tests/helpers/WebDriverIO.types.ts index c77ae8cd0..d38dd9bc7 100644 --- a/typings/tests/helpers/WebDriverIO.types.ts +++ b/typings/tests/helpers/WebDriverIO.types.ts @@ -106,10 +106,23 @@ wd.clearField({ id: 'div' }) wd.clearField({ android: 'div' }) wd.clearField({ ios: 'div' }) -wd.scrollIntoView('div', {behavior: "auto", block: "center", "inline": "center"}) +wd.scrollIntoView('div', {behavior: "auto", block: "center", inline: "center"}) +wd.setCookie() // $ExpectError wd.setCookie({name: 'name', value: 'value'}) wd.setCookie([{name: 'name', value: 'value'}]) +wd.dragAndDrop(); // $ExpectError +wd.dragAndDrop('#dragHandle'); // $ExpectError +wd.dragAndDrop('#dragHandle', '#container'); + wd.grabAllWindowHandles() // $ExpectType string[] wd.grabCurrentWindowHandle() // $ExpectType string + +wd.grabElementBoundingRect(); // $ExpectError +wd.grabElementBoundingRect('h3'); // $ExpectType number | DOMRect +wd.grabElementBoundingRect('h3', 'width'); // $ExpectType number | DOMRect + +wd.waitForValue() // $ExpectError +// wd.waitForValue('//input') // $ExpectError +wd.waitForValue('//input', "GoodValue") diff --git a/typings/tslint.json b/typings/tslint.json index af865c54c..3b4ce5d1f 100644 --- a/typings/tslint.json +++ b/typings/tslint.json @@ -7,7 +7,13 @@ "jsdoc-format": false, "max-line-length": false, "no-single-declare-module": false, - "no-unnecessary-qualifier": false + "no-unnecessary-qualifier": false, + "interface-over-type-literal": false, + "no-var-keyword": false, + "no-unnecessary-class": false, + "array-type": false, + "trim-file": false, + "no-consecutive-blank-lines": false }, "linterOptions": { "exclude": [ From 505e6c08901e45b533384c197b0bb9bff19b5f10 Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Thu, 18 Jun 2020 02:42:57 +0300 Subject: [PATCH 12/20] improve typings --- docs/webapi/grabCookie.mustache | 2 +- docs/webapi/grabNumberOfOpenTabs.mustache | 2 +- docs/webapi/grabPageScrollPosition.mustache | 2 +- docs/webapi/grabPopupText.mustache | 5 +++++ lib/helper/WebDriver.js | 6 +----- typings/index.d.ts | 5 +++++ typings/tests/helpers/WebDriverIO.types.ts | 11 +++++++++++ 7 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 docs/webapi/grabPopupText.mustache diff --git a/docs/webapi/grabCookie.mustache b/docs/webapi/grabCookie.mustache index a16ce54a9..ebdbde9df 100644 --- a/docs/webapi/grabCookie.mustache +++ b/docs/webapi/grabCookie.mustache @@ -8,4 +8,4 @@ assert(cookie.value, '123456'); ``` @param {?string} [name=null] cookie name. -@returns {Promise} attribute value \ No newline at end of file +@returns {string|string[]} attribute value diff --git a/docs/webapi/grabNumberOfOpenTabs.mustache b/docs/webapi/grabNumberOfOpenTabs.mustache index 14531fc4d..077d478a4 100644 --- a/docs/webapi/grabNumberOfOpenTabs.mustache +++ b/docs/webapi/grabNumberOfOpenTabs.mustache @@ -5,4 +5,4 @@ Resumes test execution, so **should be used inside async function with `await`** let tabs = await I.grabNumberOfOpenTabs(); ``` -@returns {Promise} number of open tabs \ No newline at end of file +@returns {Promise|number} number of open tabs diff --git a/docs/webapi/grabPageScrollPosition.mustache b/docs/webapi/grabPageScrollPosition.mustache index b34b006d6..37167f216 100644 --- a/docs/webapi/grabPageScrollPosition.mustache +++ b/docs/webapi/grabPageScrollPosition.mustache @@ -5,4 +5,4 @@ Resumes test execution, so **should be used inside an async function with `await let { x, y } = await I.grabPageScrollPosition(); ``` -@returns {Promise>} scroll position \ No newline at end of file +@returns {PageScrollPosition} scroll position diff --git a/docs/webapi/grabPopupText.mustache b/docs/webapi/grabPopupText.mustache new file mode 100644 index 000000000..20c0d53bf --- /dev/null +++ b/docs/webapi/grabPopupText.mustache @@ -0,0 +1,5 @@ +Grab the text within the popup. If no popup is visible then it will return null. +```js +await I.grabPopupText(); +``` +@returns {string} diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index 439414020..8333895fe 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -1721,11 +1721,7 @@ class WebDriver extends Helper { } /** - * Grab the text within the popup. If no popup is visible then it will return null. - * - * ```js - * await I.grabPopupText(); - * ``` + * {{> grabPopupText }} */ async grabPopupText() { try { diff --git a/typings/index.d.ts b/typings/index.d.ts index 0a8fb8416..8dd97833f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -12,6 +12,11 @@ declare namespace CodeceptJS { value: string } + interface PageScrollPosition { + x: number, + y: number + } + // Could get extended by user generated typings interface Methods extends ActorStatic {} interface I {} diff --git a/typings/tests/helpers/WebDriverIO.types.ts b/typings/tests/helpers/WebDriverIO.types.ts index d38dd9bc7..4b8ed08ec 100644 --- a/typings/tests/helpers/WebDriverIO.types.ts +++ b/typings/tests/helpers/WebDriverIO.types.ts @@ -116,9 +116,20 @@ wd.dragAndDrop(); // $ExpectError wd.dragAndDrop('#dragHandle'); // $ExpectError wd.dragAndDrop('#dragHandle', '#container'); +wd.grabCookie(); // $ExpectType string | string[] +wd.grabCookie('name'); // $ExpectType string | string[] + +wd.grabPopupText() // $ExpectType string + wd.grabAllWindowHandles() // $ExpectType string[] wd.grabCurrentWindowHandle() // $ExpectType string +wd.grabNumberOfOpenTabs() // $ExpectType number | Promise + +const psp = wd.grabPageScrollPosition() // $ExpectType PageScrollPosition +psp.x // $ExpectType number +psp.y // $ExpectType number + wd.grabElementBoundingRect(); // $ExpectError wd.grabElementBoundingRect('h3'); // $ExpectType number | DOMRect wd.grabElementBoundingRect('h3', 'width'); // $ExpectType number | DOMRect From ed37324762023e8233cf06437825575c0fae5e18 Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Thu, 18 Jun 2020 18:04:39 +0300 Subject: [PATCH 13/20] remove appium jobs from PR --- .github/workflows/appium.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/appium.yml b/.github/workflows/appium.yml index ae181295c..59845be91 100644 --- a/.github/workflows/appium.yml +++ b/.github/workflows/appium.yml @@ -4,9 +4,6 @@ on: push: branches: - master - pull_request: - branches: - - '**' env: CI: true From 2d314fefd1d45c737035cd7ba45391651b42e718 Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Thu, 18 Jun 2020 18:36:24 +0300 Subject: [PATCH 14/20] draft --- test/runner/definitions_test.js | 22 +++++++++++----------- tsconfig.json | 5 ++++- typings/index.d.ts | 2 +- typings/steps.d.ts | 8 -------- typings/tsconfig.json | 2 +- 5 files changed, 17 insertions(+), 22 deletions(-) delete mode 100644 typings/steps.d.ts diff --git a/test/runner/definitions_test.js b/test/runner/definitions_test.js index cd838e9be..48ec1b816 100644 --- a/test/runner/definitions_test.js +++ b/test/runner/definitions_test.js @@ -33,22 +33,22 @@ describe('Definitions', function () { }); describe('Static files', () => { - it('should have internal object that is available as variable codeceptjs', (done) => { + it.only('should have internal object that is available as variable codeceptjs', (done) => { exec(`${runner} def --config ${codecept_dir}/codecept.inject.po.json`, () => { const types = typesFrom(`${codecept_dir}/steps.d.ts`); types.should.be.valid; const definitionsFile = types.getSourceFileOrThrow(pathOfJSDocDefinitions); - const index = definitionsFile.getNamespaceOrThrow('CodeceptJS').getNamespaceOrThrow('index').getStructure(); - index.statements.should.containSubset([ - { declarations: [{ name: 'recorder', type: 'CodeceptJS.recorder' }] }, - { declarations: [{ name: 'event', type: 'typeof CodeceptJS.event' }] }, - { declarations: [{ name: 'output', type: 'typeof CodeceptJS.output' }] }, - { declarations: [{ name: 'config', type: 'typeof CodeceptJS.Config' }] }, - { declarations: [{ name: 'container', type: 'typeof CodeceptJS.Container' }] }, - ]); - const codeceptjs = types.getSourceFileOrThrow(pathOfStaticDefinitions).getVariableDeclarationOrThrow('codeceptjs').getStructure(); - codeceptjs.type.should.equal('typeof CodeceptJS.index'); + // const index = definitionsFile.getNamespaceOrThrow('CodeceptJS').getNamespaceOrThrow('index').getStructure(); + // index.statements.should.containSubset([ + // { declarations: [{ name: 'recorder', type: 'CodeceptJS.recorder' }] }, + // { declarations: [{ name: 'event', type: 'typeof CodeceptJS.event' }] }, + // { declarations: [{ name: 'output', type: 'typeof CodeceptJS.output' }] }, + // { declarations: [{ name: 'config', type: 'typeof CodeceptJS.Config' }] }, + // { declarations: [{ name: 'container', type: 'typeof CodeceptJS.Container' }] }, + // ]); + // const codeceptjs = types.getSourceFileOrThrow(pathOfStaticDefinitions).getVariableDeclarationOrThrow('codeceptjs').getStructure(); + // codeceptjs.type.should.equal('typeof CodeceptJS.index'); done(); }); }); diff --git a/tsconfig.json b/tsconfig.json index b7c3edd1f..15445914a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,5 +16,8 @@ "include": [ "lib", "typings" + ], + "exclude": [ + "typings/tests" ] -} \ No newline at end of file +} diff --git a/typings/index.d.ts b/typings/index.d.ts index 8dd97833f..bfc26e2fb 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -23,7 +23,7 @@ declare namespace CodeceptJS { interface IHook {} interface IScenario {} interface SupportObject { - I: I; + I: CodeceptJS.I; } namespace Translation { interface Actions {} diff --git a/typings/steps.d.ts b/typings/steps.d.ts deleted file mode 100644 index 490e6c9b9..000000000 --- a/typings/steps.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace CodeceptJS { - interface SupportObject { I: I } - interface Methods extends WebDriver {} - interface I extends WithTranslation {} - namespace Translation { - interface Actions {} - } -} diff --git a/typings/tsconfig.json b/typings/tsconfig.json index 298478b2e..477edace9 100644 --- a/typings/tsconfig.json +++ b/typings/tsconfig.json @@ -16,7 +16,7 @@ "forceConsistentCasingInFileNames": true }, "include": [ - "**/*.ts", + // "**/*.ts", "steps.d.ts" ] } From 46990b1d3c18cfdd4847a1b511815d081008c34e Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Thu, 18 Jun 2020 22:23:33 +0300 Subject: [PATCH 15/20] fix --- .eslintrc.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index b2a4faf69..33d9c6e9a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,7 +11,6 @@ "no-undef": 0, "prefer-destructuring": 0, "no-param-reassign": 0, - "no-multiple-empty-lines": 0, "max-len": 0, "camelcase": 0, "no-shadow": 0, From 8f3bc480bae219d93079f04270f68477d6e80533 Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Thu, 18 Jun 2020 23:15:40 +0300 Subject: [PATCH 16/20] fix tests --- test/runner/definitions_test.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/runner/definitions_test.js b/test/runner/definitions_test.js index 33a60636c..21ef4cfc9 100644 --- a/test/runner/definitions_test.js +++ b/test/runner/definitions_test.js @@ -33,22 +33,22 @@ describe('Definitions', function () { }); describe('Static files', () => { - it.only('should have internal object that is available as variable codeceptjs', (done) => { + it('should have internal object that is available as variable codeceptjs', (done) => { exec(`${runner} def --config ${codecept_dir}/codecept.inject.po.json`, () => { const types = typesFrom(`${codecept_dir}/steps.d.ts`); types.should.be.valid; const definitionsFile = types.getSourceFileOrThrow(pathOfJSDocDefinitions); - // const index = definitionsFile.getNamespaceOrThrow('CodeceptJS').getNamespaceOrThrow('index').getStructure(); - // index.statements.should.containSubset([ - // { declarations: [{ name: 'recorder', type: 'CodeceptJS.recorder' }] }, - // { declarations: [{ name: 'event', type: 'typeof CodeceptJS.event' }] }, - // { declarations: [{ name: 'output', type: 'typeof CodeceptJS.output' }] }, - // { declarations: [{ name: 'config', type: 'typeof CodeceptJS.Config' }] }, - // { declarations: [{ name: 'container', type: 'typeof CodeceptJS.Container' }] }, - // ]); - // const codeceptjs = types.getSourceFileOrThrow(pathOfStaticDefinitions).getVariableDeclarationOrThrow('codeceptjs').getStructure(); - // codeceptjs.type.should.equal('typeof CodeceptJS.index'); + const index = definitionsFile.getNamespaceOrThrow('CodeceptJS').getNamespaceOrThrow('index').getStructure(); + index.statements.should.containSubset([ + { declarations: [{ name: 'recorder', type: 'CodeceptJS.recorder' }] }, + { declarations: [{ name: 'event', type: 'typeof CodeceptJS.event' }] }, + { declarations: [{ name: 'output', type: 'typeof CodeceptJS.output' }] }, + { declarations: [{ name: 'config', type: 'typeof CodeceptJS.Config' }] }, + { declarations: [{ name: 'container', type: 'typeof CodeceptJS.Container' }] }, + ]); + const codeceptjs = types.getSourceFileOrThrow(pathOfStaticDefinitions).getVariableDeclarationOrThrow('codeceptjs').getStructure(); + codeceptjs.type.should.equal('typeof CodeceptJS.index'); done(); }); }); @@ -155,7 +155,7 @@ describe('Definitions', function () { returned.should.containSubset([ { properties: [ - { name: 'I', type: 'CodeceptJS.I' }, + { name: 'I', type: 'I' }, { name: 'MyPage', type: 'MyPage' }, ], }, @@ -172,7 +172,7 @@ describe('Definitions', function () { const definitionsFile = types.getSourceFileOrThrow(pathOfStaticDefinitions); const returned = getReturnStructure(definitionsFile.getFunctionOrThrow('inject')); returned.should.containSubset([{ - properties: [{ name: 'I', type: 'CodeceptJS.I' }], + properties: [{ name: 'I', type: 'I' }], }]); done(); }); @@ -186,7 +186,7 @@ describe('Definitions', function () { const definitionsFile = types.getSourceFileOrThrow(`${codecept_dir}/steps.d.ts`); const CallbackOrder = definitionsFile.getNamespaceOrThrow('CodeceptJS').getInterfaceOrThrow('SupportObject').getStructure(); CallbackOrder.properties.should.containSubset([ - { name: 'I', type: 'CodeceptJS.I' }, + { name: 'I', type: 'I' }, { name: 'MyPage', type: 'MyPage' }, { name: 'SecondPage', type: 'SecondPage' }, ]); From fad6bb889e56c6177ec366932376628569990124 Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Fri, 19 Jun 2020 02:48:53 +0300 Subject: [PATCH 17/20] add tests for all wdio methods --- docs/webapi/closeCurrentTab.mustache | 5 + docs/webapi/closeOtherTabs.mustache | 6 + docs/webapi/grabAllWindowHandles.mustache | 2 +- docs/webapi/grabBrowserLogs.mustache | 2 +- docs/webapi/grabCookie.mustache | 2 +- docs/webapi/grabCurrentWindowHandle.mustache | 2 +- docs/webapi/grabElementBoundingRect.mustache | 2 +- docs/webapi/grabNumberOfOpenTabs.mustache | 2 +- docs/webapi/grabPageScrollPosition.mustache | 2 +- docs/webapi/grabPopupText.mustache | 2 +- docs/webapi/openNewTab.mustache | 5 + docs/webapi/seeTitleEquals.mustache | 7 + docs/webapi/selectOption.mustache | 4 +- docs/webapi/setGeoLocation.mustache | 2 +- docs/webapi/switchToNextTab.mustache | 9 + docs/webapi/switchToPreviousTab.mustache | 9 + lib/helper/WebDriver.js | 79 +--- typings/tests/helpers/WebDriverIO.types.ts | 370 +++++++++++++++++-- typings/tsconfig.json | 3 +- 19 files changed, 398 insertions(+), 117 deletions(-) create mode 100644 docs/webapi/closeCurrentTab.mustache create mode 100644 docs/webapi/closeOtherTabs.mustache create mode 100644 docs/webapi/openNewTab.mustache create mode 100644 docs/webapi/seeTitleEquals.mustache create mode 100644 docs/webapi/switchToNextTab.mustache create mode 100644 docs/webapi/switchToPreviousTab.mustache diff --git a/docs/webapi/closeCurrentTab.mustache b/docs/webapi/closeCurrentTab.mustache new file mode 100644 index 000000000..030ed99e8 --- /dev/null +++ b/docs/webapi/closeCurrentTab.mustache @@ -0,0 +1,5 @@ + Close current tab. + + ```js + I.closeCurrentTab(); + ``` diff --git a/docs/webapi/closeOtherTabs.mustache b/docs/webapi/closeOtherTabs.mustache new file mode 100644 index 000000000..68d03c036 --- /dev/null +++ b/docs/webapi/closeOtherTabs.mustache @@ -0,0 +1,6 @@ + Close all tabs except for the current one. + + + ```js + I.closeOtherTabs(); + ``` diff --git a/docs/webapi/grabAllWindowHandles.mustache b/docs/webapi/grabAllWindowHandles.mustache index 5f29c1ed7..fdc86db55 100644 --- a/docs/webapi/grabAllWindowHandles.mustache +++ b/docs/webapi/grabAllWindowHandles.mustache @@ -4,4 +4,4 @@ Useful for referencing a specific handle when calling `I.switchToWindow(handle)` ```js const windows = await I.grabAllWindowHandles(); ``` -@returns {Array} +@returns {Promise} diff --git a/docs/webapi/grabBrowserLogs.mustache b/docs/webapi/grabBrowserLogs.mustache index 436d44bf9..f504f2357 100644 --- a/docs/webapi/grabBrowserLogs.mustache +++ b/docs/webapi/grabBrowserLogs.mustache @@ -6,4 +6,4 @@ let logs = await I.grabBrowserLogs(); console.log(JSON.stringify(logs)) ``` -@returns {Promise>} all browser logs \ No newline at end of file +@returns {Promise|undefined} all browser logs diff --git a/docs/webapi/grabCookie.mustache b/docs/webapi/grabCookie.mustache index ebdbde9df..730e609bd 100644 --- a/docs/webapi/grabCookie.mustache +++ b/docs/webapi/grabCookie.mustache @@ -8,4 +8,4 @@ assert(cookie.value, '123456'); ``` @param {?string} [name=null] cookie name. -@returns {string|string[]} attribute value +@returns {Promise|Promise} attribute value diff --git a/docs/webapi/grabCurrentWindowHandle.mustache b/docs/webapi/grabCurrentWindowHandle.mustache index 48d75c9c9..b2ff9d489 100644 --- a/docs/webapi/grabCurrentWindowHandle.mustache +++ b/docs/webapi/grabCurrentWindowHandle.mustache @@ -3,4 +3,4 @@ Useful for referencing it when calling `I.switchToWindow(handle)` ```js const window = await I.grabCurrentWindowHandle(); ``` -@returns {string} +@returns {Promise} diff --git a/docs/webapi/grabElementBoundingRect.mustache b/docs/webapi/grabElementBoundingRect.mustache index dcb90013b..8d4d28d5b 100644 --- a/docs/webapi/grabElementBoundingRect.mustache +++ b/docs/webapi/grabElementBoundingRect.mustache @@ -17,4 +17,4 @@ const width = await I.grabElementBoundingRect('h3', 'width'); ``` @param {LocatorOrString} locator element located by CSS|XPath|strict locator. @param {string=} elementSize x, y, width or height of the given element. -@returns {DOMRect|number} Element bounding rectangle +@returns {Promise|Promise} Element bounding rectangle diff --git a/docs/webapi/grabNumberOfOpenTabs.mustache b/docs/webapi/grabNumberOfOpenTabs.mustache index 077d478a4..075f2b2ac 100644 --- a/docs/webapi/grabNumberOfOpenTabs.mustache +++ b/docs/webapi/grabNumberOfOpenTabs.mustache @@ -5,4 +5,4 @@ Resumes test execution, so **should be used inside async function with `await`** let tabs = await I.grabNumberOfOpenTabs(); ``` -@returns {Promise|number} number of open tabs +@returns {Promise} number of open tabs diff --git a/docs/webapi/grabPageScrollPosition.mustache b/docs/webapi/grabPageScrollPosition.mustache index 37167f216..b6a2311d1 100644 --- a/docs/webapi/grabPageScrollPosition.mustache +++ b/docs/webapi/grabPageScrollPosition.mustache @@ -5,4 +5,4 @@ Resumes test execution, so **should be used inside an async function with `await let { x, y } = await I.grabPageScrollPosition(); ``` -@returns {PageScrollPosition} scroll position +@returns {Promise} scroll position diff --git a/docs/webapi/grabPopupText.mustache b/docs/webapi/grabPopupText.mustache index 20c0d53bf..964b49218 100644 --- a/docs/webapi/grabPopupText.mustache +++ b/docs/webapi/grabPopupText.mustache @@ -2,4 +2,4 @@ Grab the text within the popup. If no popup is visible then it will return null. ```js await I.grabPopupText(); ``` -@returns {string} +@returns {Promise} diff --git a/docs/webapi/openNewTab.mustache b/docs/webapi/openNewTab.mustache new file mode 100644 index 000000000..a81321ea2 --- /dev/null +++ b/docs/webapi/openNewTab.mustache @@ -0,0 +1,5 @@ + Open new tab and switch to it. + + ```js + I.openNewTab(); + ``` diff --git a/docs/webapi/seeTitleEquals.mustache b/docs/webapi/seeTitleEquals.mustache new file mode 100644 index 000000000..9d157cb32 --- /dev/null +++ b/docs/webapi/seeTitleEquals.mustache @@ -0,0 +1,7 @@ + Checks that title is equal to provided one. + + ```js + I.seeTitleEquals('Test title.'); + ``` + + @param {string} text value to check. diff --git a/docs/webapi/selectOption.mustache b/docs/webapi/selectOption.mustache index efa2e6b32..764dd8e44 100644 --- a/docs/webapi/selectOption.mustache +++ b/docs/webapi/selectOption.mustache @@ -16,5 +16,5 @@ Provide an array for the second argument to select multiple options. ```js I.selectOption('Which OS do you use?', ['Android', 'iOS']); ``` -@param {CodeceptJS.LocatorOrString} select field located by label|name|CSS|XPath|strict locator. -@param {string|Array<*>} option visible text or value of option. \ No newline at end of file +@param {LocatorOrString} select field located by label|name|CSS|XPath|strict locator. +@param {string|Array<*>} option visible text or value of option. diff --git a/docs/webapi/setGeoLocation.mustache b/docs/webapi/setGeoLocation.mustache index ab55fdeb0..ce45fd76d 100644 --- a/docs/webapi/setGeoLocation.mustache +++ b/docs/webapi/setGeoLocation.mustache @@ -8,4 +8,4 @@ I.setGeoLocation(121.21, 11.56, 10); @param {number} latitude to set. @param {number} longitude to set -@param {number} altitude (optional, null by default) to set \ No newline at end of file +@param {number=} altitude (optional, null by default) to set diff --git a/docs/webapi/switchToNextTab.mustache b/docs/webapi/switchToNextTab.mustache new file mode 100644 index 000000000..114a8c32f --- /dev/null +++ b/docs/webapi/switchToNextTab.mustache @@ -0,0 +1,9 @@ + Switch focus to a particular tab by its number. It waits tabs loading and then switch tab. + + ```js + I.switchToNextTab(); + I.switchToNextTab(2); + ``` + + @param {number} [num] (optional) number of tabs to switch forward, default: 1. + @param {number | null} [sec] (optional) time in seconds to wait. diff --git a/docs/webapi/switchToPreviousTab.mustache b/docs/webapi/switchToPreviousTab.mustache new file mode 100644 index 000000000..4d9044114 --- /dev/null +++ b/docs/webapi/switchToPreviousTab.mustache @@ -0,0 +1,9 @@ + Switch focus to a particular tab by its number. It waits tabs loading and then switch tab. + + ```js + I.switchToPreviousTab(); + I.switchToPreviousTab(2); + ``` + + @param {number} [num] (optional) number of tabs to switch backward, default: 1. + @param {number?} [sec] (optional) time in seconds to wait. diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index 81670c18b..81c933692 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -1194,7 +1194,6 @@ class WebDriver extends Helper { /** * {{> seeInTitle }} - * */ async seeInTitle(text) { const title = await this.browser.getTitle(); @@ -1202,13 +1201,7 @@ class WebDriver extends Helper { } /** - * Checks that title is equal to provided one. - * - * ```js - * I.seeTitleEquals('Test title.'); - * ``` - * - * @param {string} text value to check. + * {{> seeTitleEquals }} */ async seeTitleEquals(text) { const title = await this.browser.getTitle(); @@ -1217,7 +1210,6 @@ class WebDriver extends Helper { /** * {{> dontSeeInTitle }} - * */ async dontSeeInTitle(text) { const title = await this.browser.getTitle(); @@ -1226,7 +1218,6 @@ class WebDriver extends Helper { /** * {{> grabTitle }} - * */ async grabTitle() { const title = await this.browser.getTitle(); @@ -1352,13 +1343,7 @@ class WebDriver extends Helper { } /** - * Get JS log from browser. Log buffer is reset after each request. - * - * ```js - * let logs = await I.grabBrowserLogs(); - * console.log(JSON.stringify(logs)) - * ``` - * @returns {Promise} + * {{> grabBrowserLogs }} */ async grabBrowserLogs() { if (this.browser.isW3C) { @@ -1575,7 +1560,6 @@ class WebDriver extends Helper { /** * {{> moveCursorTo }} - * */ async moveCursorTo(locator, xOffset, yOffset) { const res = await this._locate(withStrictLocator(locator), true); @@ -1587,7 +1571,6 @@ class WebDriver extends Helper { /** * {{> saveScreenshot }} - * */ async saveScreenshot(fileName, fullPage = false) { const outputFile = screenshotOutputFolder(fileName); @@ -1639,7 +1622,6 @@ class WebDriver extends Helper { /** * {{> clearCookie }} - * */ async clearCookie(cookie) { return this.browser.deleteCookies(cookie); @@ -1647,7 +1629,6 @@ class WebDriver extends Helper { /** * {{> seeCookie }} - * */ async seeCookie(name) { const cookie = await this.browser.getCookies([name]); @@ -1656,7 +1637,6 @@ class WebDriver extends Helper { /** * {{> dontSeeCookie }} - * */ async dontSeeCookie(name) { const cookie = await this.browser.getCookies([name]); @@ -1665,7 +1645,6 @@ class WebDriver extends Helper { /** * {{> grabCookie }} - * */ async grabCookie(name) { if (!name) return this.browser.getCookies(); @@ -1910,18 +1889,14 @@ class WebDriver extends Helper { * // ... do something * await I.switchToWindow( window ); * ``` + * @param {string} window name of window handle. */ async switchToWindow(window) { await this.browser.switchToWindow(window); } /** - * Close all tabs except for the current one. - * - * - * ```js - * I.closeOtherTabs(); - * ``` + * {{> closeOtherTabs }} */ async closeOtherTabs() { const handles = await this.browser.getWindowHandles(); @@ -1937,7 +1912,6 @@ class WebDriver extends Helper { /** * {{> wait }} - * */ async wait(sec) { return new Promise(resolve => setTimeout(resolve, sec * 1000)); @@ -1945,7 +1919,6 @@ class WebDriver extends Helper { /** * {{> waitForEnabled }} - * */ async waitForEnabled(locator, sec = null) { const aSec = sec || this.options.waitForTimeout; @@ -2204,7 +2177,6 @@ class WebDriver extends Helper { /** * {{> waitForInvisible }} - * */ async waitForInvisible(locator, sec = null) { const aSec = sec || this.options.waitForTimeout; @@ -2226,20 +2198,13 @@ class WebDriver extends Helper { /** * {{> waitToHide }} - * */ async waitToHide(locator, sec = null) { return this.waitForInvisible(locator, sec); } - async waitForStalenessOf(locator, sec = null) { - console.log('waitForStalenessOf deprecated. Use waitForDetached instead'); - return this.waitForDetached(locator, sec); - } - /** * {{> waitForDetached }} - * */ async waitForDetached(locator, sec = null) { const aSec = sec || this.options.waitForTimeout; @@ -2263,7 +2228,6 @@ class WebDriver extends Helper { /** * {{> waitForFunction }} - * */ async waitForFunction(fn, argsOrSec = null, sec = null) { let args = []; @@ -2284,7 +2248,6 @@ class WebDriver extends Helper { /** * {{> waitUntil }} - * */ async waitUntil(fn, sec = null, timeoutMsg = null, interval = null) { const aSec = sec || this.options.waitForTimeout; @@ -2297,7 +2260,6 @@ class WebDriver extends Helper { /** * {{> switchTo }} - * */ async switchTo(locator) { this.browser.isInsideFrame = true; @@ -2315,15 +2277,7 @@ class WebDriver extends Helper { } /** - * Switch focus to a particular tab by its number. It waits tabs loading and then switch tab. - * - * ```js - * I.switchToNextTab(); - * I.switchToNextTab(2); - * ``` - * - * @param {number} [num] (optional) number of tabs to switch forward, default: 1. - * @param {number | null} [sec] (optional) time in seconds to wait. + * {{> switchToNextTab }} */ async switchToNextTab(num = 1, sec = null) { const aSec = sec || this.options.waitForTimeout; @@ -2354,15 +2308,7 @@ class WebDriver extends Helper { } /** - * Switch focus to a particular tab by its number. It waits tabs loading and then switch tab. - * - * ```js - * I.switchToPreviousTab(); - * I.switchToPreviousTab(2); - * ``` - * - * @param {number} [num] (optional) number of tabs to switch backward, default: 1. - * @param {number?} [sec] (optional) time in seconds to wait. + * {{> switchToPreviousTab }} */ async switchToPreviousTab(num = 1, sec = null) { const aSec = sec || this.options.waitForTimeout; @@ -2393,11 +2339,7 @@ class WebDriver extends Helper { } /** - * Close current tab. - * - * ```js - * I.closeCurrentTab(); - * ``` + * {{> closeCurrentTab }} */ async closeCurrentTab() { await this.browser.closeWindow(); @@ -2406,11 +2348,7 @@ class WebDriver extends Helper { } /** - * Open new tab and switch to it. - * - * ```js - * I.openNewTab(); - * ``` + * {{> openNewTab }} */ async openNewTab(url = 'about:blank', windowName = null) { const client = this.browser; @@ -2484,7 +2422,6 @@ class WebDriver extends Helper { /** * {{> setGeoLocation }} - * */ async setGeoLocation(latitude, longitude, altitude = null) { if (altitude) { diff --git a/typings/tests/helpers/WebDriverIO.types.ts b/typings/tests/helpers/WebDriverIO.types.ts index 4b8ed08ec..994b862ff 100644 --- a/typings/tests/helpers/WebDriverIO.types.ts +++ b/typings/tests/helpers/WebDriverIO.types.ts @@ -1,5 +1,8 @@ const wd = new CodeceptJS.WebDriver() +const str = 'text' +const num = 1 + wd.amOnPage() // $ExpectError wd.amOnPage('') // $ExpectType void @@ -77,25 +80,25 @@ wd.rightClick('div', { ios: '//div' }) wd.fillField() // $ExpectError wd.fillField('div') // $ExpectError -wd.fillField('div', 'value') // $ExpectType void -wd.fillField({ css: 'div' }, 'value') -wd.fillField({ xpath: '//div' }, 'value') -wd.fillField({ name: 'div' }, 'value') -wd.fillField({ id: 'div' }, 'value') -wd.fillField({ android: 'div' }, 'value') -wd.fillField({ ios: 'div' }, 'value') -wd.fillField(locate('div'), 'value') +wd.fillField('div', str) // $ExpectType void +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) +wd.fillField(locate('div'), str) wd.appendField() // $ExpectError wd.appendField('div') // $ExpectError -wd.appendField('div', 'value') // $ExpectType void -wd.appendField({ css: 'div' }, 'value') -wd.appendField({ xpath: '//div' }, 'value') -wd.appendField({ name: 'div' }, 'value') -wd.appendField({ id: 'div' }, 'value') -wd.appendField({ android: 'div' }, 'value') -wd.appendField({ ios: 'div' }, 'value') -wd.appendField(locate('div'), 'value') +wd.appendField('div', str) // $ExpectType void +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) +wd.appendField(locate('div'), str) wd.clearField() // $ExpectError wd.clearField('div') @@ -106,34 +109,335 @@ 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 + +wd.attachFile() // $ExpectError +wd.attachFile('div') // $ExpectError +wd.attachFile('div', str) // $ExpectType void + +wd.checkOption() // $ExpectError +wd.checkOption('div') // $ExpectType void + +wd.uncheckOption() // $ExpectError +wd.uncheckOption('div') // $ExpectType void + +wd.seeInTitle() // $ExpectError +wd.seeInTitle(str) // $ExpectType void + +wd.seeTitleEquals() // $ExpectError +wd.seeTitleEquals(str) // $ExpectType void + +wd.dontSeeInTitle() // $ExpectError +wd.dontSeeInTitle(str) // $ExpectType void + +wd.see() // $ExpectError +wd.see(str) // $ExpectType void +wd.see(str, 'div') // $ExpectType void + +wd.dontSee() // $ExpectError +wd.dontSee(str) // $ExpectType void +wd.dontSee(str, 'div') // $ExpectType void + +wd.seeTextEquals() // $ExpectError +wd.seeTextEquals(str) // $ExpectType void +wd.seeTextEquals(str, 'div') // $ExpectType void + +wd.seeInField() // $ExpectError +wd.seeInField('div') // $ExpectError +wd.seeInField('div', str) // $ExpectType void + +wd.dontSeeInField() // $ExpectError +wd.dontSeeInField('div') // $ExpectError +wd.dontSeeInField('div', str) // $ExpectType void + +wd.seeCheckboxIsChecked() // $ExpectError +wd.seeCheckboxIsChecked('div') // $ExpectType void + +wd.dontSeeCheckboxIsChecked() // $ExpectError +wd.dontSeeCheckboxIsChecked('div') // $ExpectType void + +wd.seeElement() // $ExpectError +wd.seeElement('div') // $ExpectType void + +wd.dontSeeElement() // $ExpectError +wd.dontSeeElement('div') // $ExpectType void + +wd.seeElementInDOM() // $ExpectError +wd.seeElementInDOM('div') // $ExpectType void + +wd.dontSeeElementInDOM() // $ExpectError +wd.dontSeeElementInDOM('div') // $ExpectType void + +wd.seeInSource() // $ExpectError +wd.seeInSource(str) // $ExpectType void + +wd.dontSeeInSource() // $ExpectError +wd.dontSeeInSource(str) // $ExpectType void + +wd.seeNumberOfElements() // $ExpectError +wd.seeNumberOfElements('div') // $ExpectError +wd.seeNumberOfElements('div', num) // $ExpectType void + +wd.seeNumberOfVisibleElements() // $ExpectError +wd.seeNumberOfVisibleElements('div') // $ExpectError +wd.seeNumberOfVisibleElements('div', num) // $ExpectType void + +wd.seeCssPropertiesOnElements() // $ExpectError +wd.seeCssPropertiesOnElements('div') // $ExpectError +wd.seeCssPropertiesOnElements('div', str) // $ExpectType void + +wd.seeAttributesOnElements() // $ExpectError +wd.seeAttributesOnElements('div') // $ExpectError +wd.seeAttributesOnElements('div', str) // $ExpectType void + +wd.seeInCurrentUrl() // $ExpectError +wd.seeInCurrentUrl(str) // $ExpectType void + +wd.seeCurrentUrlEquals() // $ExpectError +wd.seeCurrentUrlEquals(str) // $ExpectType void + +wd.dontSeeInCurrentUrl() // $ExpectError +wd.dontSeeInCurrentUrl(str) // $ExpectType void + +wd.dontSeeCurrentUrlEquals() // $ExpectError +wd.dontSeeCurrentUrlEquals(str) // $ExpectType void + +wd.executeScript() // $ExpectError +wd.executeScript(str) // $ExpectType Promise +wd.executeScript(() => {}) // $ExpectType Promise +wd.executeScript(() => {}, {}) // $ExpectType Promise + +wd.executeAsyncScript() // $ExpectError +wd.executeAsyncScript(str) // $ExpectType Promise +wd.executeAsyncScript(() => {}) // $ExpectType Promise +wd.executeAsyncScript(() => {}, {}) // $ExpectType Promise + +wd.scrollIntoView() // $ExpectError +wd.scrollIntoView('div') // $ExpectError wd.scrollIntoView('div', {behavior: "auto", block: "center", inline: "center"}) +wd.scrollTo() // $ExpectError +wd.scrollTo('div') // $ExpectType void +wd.scrollTo('div', num, num) // $ExpectType void + +wd.moveCursorTo() // $ExpectError +wd.moveCursorTo('div') // $ExpectType void +wd.moveCursorTo('div', num, num) // $ExpectType void + +wd.saveScreenshot() // $ExpectError +wd.saveScreenshot(str) // $ExpectType void +wd.saveScreenshot(str, true) // $ExpectType void + wd.setCookie() // $ExpectError -wd.setCookie({name: 'name', value: 'value'}) -wd.setCookie([{name: 'name', value: 'value'}]) +wd.setCookie({name: str, value: str}) // $ExpectType void +wd.setCookie([{name: str, value: str}]) // $ExpectType void + +wd.clearCookie() // $ExpectType void +wd.clearCookie(str) // $ExpectType void + +wd.seeCookie() // $ExpectError +wd.seeCookie(str) // $ExpectType void + +wd.acceptPopup() // $ExpectType void + +wd.cancelPopup() // $ExpectType void + +wd.seeInPopup() // $ExpectError +wd.seeInPopup(str) // $ExpectType void + +wd.pressKeyDown() // $ExpectError +wd.pressKeyDown(str) // $ExpectType void + +wd.pressKeyUp() // $ExpectError +wd.pressKeyUp(str) // $ExpectType void + +wd.pressKey() // $ExpectError +wd.pressKey(str) // $ExpectType void + +wd.type() // $ExpectError +wd.type(str) // $ExpectType void + +wd.resizeWindow() // $ExpectError +wd.resizeWindow(num) // $ExpectError +wd.resizeWindow(num, num) // $ExpectType void + +wd.dragAndDrop() // $ExpectError +wd.dragAndDrop('div') // $ExpectError +wd.dragAndDrop('div', 'div') // $ExpectType void + +wd.dragSlider() // $ExpectError +wd.dragSlider('div', num) // $ExpectType void + +wd.switchToWindow() // $ExpectError +wd.switchToWindow(str) // $ExpectType void + +wd.closeOtherTabs() // $ExpectType void + +wd.wait() // $ExpectError +wd.wait(num) // $ExpectType void + +wd.waitForEnabled() // $ExpectError +wd.waitForEnabled('div') // $ExpectType void +wd.waitForEnabled('div', num) // $ExpectType void + +wd.waitForElement() // $ExpectError +wd.waitForElement('div') // $ExpectType void +wd.waitForElement('div', num) // $ExpectType void + +wd.waitForClickable() // $ExpectError +wd.waitForClickable('div') // $ExpectType void +wd.waitForClickable('div', num) // $ExpectType void + +wd.waitUntilExists() // $ExpectError +wd.waitUntilExists('div') // $ExpectType void +wd.waitUntilExists('div', num) // $ExpectType void + +wd.waitForVisible() // $ExpectError +wd.waitForVisible('div') // $ExpectType void +wd.waitForVisible('div', num) // $ExpectType void + +wd.waitForInvisible() // $ExpectError +wd.waitForInvisible('div') // $ExpectType void +wd.waitForInvisible('div', num) // $ExpectType void + +wd.waitToHide() // $ExpectError +wd.waitToHide('div') // $ExpectType void +wd.waitToHide('div', num) // $ExpectType void + +wd.waitForDetached() // $ExpectError +wd.waitForDetached('div') // $ExpectType void +wd.waitForDetached('div', num) // $ExpectType void + +wd.waitForFunction() // $ExpectError +wd.waitForFunction('div') // $ExpectType void +wd.waitForFunction(() => {}) // $ExpectType void +wd.waitForFunction(() => {}, [num], num) // $ExpectType void +wd.waitForFunction(() => {}, [str], num) // $ExpectType void + +wd.waitInUrl() // $ExpectError +wd.waitInUrl(str) // $ExpectType void +wd.waitInUrl(str, num) // $ExpectType void + +wd.waitForText() // $ExpectError +wd.waitForText(str) // $ExpectType void +wd.waitForText(str, num, str) // $ExpectType void + +wd.waitForValue() // $ExpectError +wd.waitForValue(str) // $ExpectError +wd.waitForValue(str, str) // $ExpectType void +wd.waitForValue(str, str, num) // $ExpectType void + +wd.waitNumberOfVisibleElements() // $ExpectError +wd.waitNumberOfVisibleElements('div') // $ExpectError +wd.waitNumberOfVisibleElements(str, num) // $ExpectType void +wd.waitNumberOfVisibleElements(str, num, num) // $ExpectType void + +wd.waitUrlEquals() // $ExpectError +wd.waitUrlEquals(str) // $ExpectType void +wd.waitUrlEquals(str, num) // $ExpectType void + +wd.waitUntil() // $ExpectError +wd.waitUntil(() => {}) // $ExpectType void +wd.waitUntil(str) // $ExpectType void +wd.waitUntil(str, num, str, num) // $ExpectType void +wd.waitUntil(() => {}, num, str, num) // $ExpectType void + +wd.switchTo() // $ExpectError +wd.switchTo('div') // $ExpectType void + +wd.switchToNextTab(num, num) // $ExpectType void + +wd.switchToPreviousTab(num, num) // $ExpectType void + +wd.closeCurrentTab() // $ExpectType void + +wd.openNewTab() // $ExpectType void + +wd.refreshPage() // $ExpectType void + +wd.scrollPageToTop() // $ExpectType void + +wd.scrollPageToBottom() // $ExpectType void + +wd.setGeoLocation() // $ExpectError +wd.setGeoLocation(num) // $ExpectError +wd.setGeoLocation(num, num) // $ExpectType void +wd.setGeoLocation(num, num, num) // $ExpectType void + +wd.dontSeeCookie() // $ExpectError +wd.dontSeeCookie(str) // $ExpectType void wd.dragAndDrop(); // $ExpectError wd.dragAndDrop('#dragHandle'); // $ExpectError wd.dragAndDrop('#dragHandle', '#container'); -wd.grabCookie(); // $ExpectType string | string[] -wd.grabCookie('name'); // $ExpectType string | string[] +wd.grabTextFromAll() // $ExpectError +wd.grabTextFromAll('div') // $ExpectType Promise -wd.grabPopupText() // $ExpectType string +wd.grabTextFrom() // $ExpectError +wd.grabTextFrom('div') // $ExpectType Promise -wd.grabAllWindowHandles() // $ExpectType string[] -wd.grabCurrentWindowHandle() // $ExpectType string +wd.grabHTMLFromAll() // $ExpectError +wd.grabHTMLFromAll('div') // $ExpectType Promise -wd.grabNumberOfOpenTabs() // $ExpectType number | Promise +wd.grabHTMLFrom() // $ExpectError +wd.grabHTMLFrom('div') // $ExpectType Promise -const psp = wd.grabPageScrollPosition() // $ExpectType PageScrollPosition -psp.x // $ExpectType number -psp.y // $ExpectType number +wd.grabValueFromAll() // $ExpectError +wd.grabValueFromAll('div') // $ExpectType Promise -wd.grabElementBoundingRect(); // $ExpectError -wd.grabElementBoundingRect('h3'); // $ExpectType number | DOMRect -wd.grabElementBoundingRect('h3', 'width'); // $ExpectType number | DOMRect +wd.grabValueFrom() // $ExpectError +wd.grabValueFrom('div') // $ExpectType Promise -wd.waitForValue() // $ExpectError -// wd.waitForValue('//input') // $ExpectError -wd.waitForValue('//input', "GoodValue") +wd.grabCssPropertyFromAll() // $ExpectError +wd.grabCssPropertyFromAll('div') // $ExpectError +wd.grabCssPropertyFromAll('div', 'color') // $ExpectType Promise + +wd.grabCssPropertyFrom() // $ExpectError +wd.grabCssPropertyFrom('div') // $ExpectError +wd.grabCssPropertyFrom('div', 'color') // $ExpectType Promise + +wd.grabAttributeFromAll() // $ExpectError +wd.grabAttributeFromAll('div') // $ExpectError +wd.grabAttributeFromAll('div', 'style') // $ExpectType Promise + +wd.grabAttributeFrom() // $ExpectError +wd.grabAttributeFrom('div') // $ExpectError +wd.grabAttributeFrom('div', 'style') // $ExpectType Promise + +wd.grabTitle() // $ExpectType Promise + +wd.grabSource() // $ExpectType Promise + +wd.grabBrowserLogs() // $ExpectType Promise | undefined + +wd.grabCurrentUrl() // $ExpectType Promise + +wd.grabNumberOfVisibleElements() // $ExpectError +wd.grabNumberOfVisibleElements('div') // $ExpectType Promise + +wd.grabCookie(); // $ExpectType Promise | Promise +wd.grabCookie('name'); // $ExpectType Promise | Promise + +wd.grabPopupText() // $ExpectType Promise + +wd.grabAllWindowHandles() // $ExpectType Promise +wd.grabCurrentWindowHandle() // $ExpectType Promise + +wd.grabNumberOfOpenTabs() // $ExpectType Promise + +const psp = wd.grabPageScrollPosition() // $ExpectType Promise +psp.then( + result => { + result.x // $ExpectType number + result.y // $ExpectType number + } +) + +wd.grabGeoLocation() // $ExpectType Promise<{ latitude: number; longitude: number; altitude: number; }> + +wd.grabElementBoundingRect(); // $ExpectError +wd.grabElementBoundingRect('h3'); // $ExpectType Promise | Promise +wd.grabElementBoundingRect('h3', 'width') // $ExpectType Promise | Promise diff --git a/typings/tsconfig.json b/typings/tsconfig.json index 477edace9..2ec0512ec 100644 --- a/typings/tsconfig.json +++ b/typings/tsconfig.json @@ -16,7 +16,6 @@ "forceConsistentCasingInFileNames": true }, "include": [ - // "**/*.ts", - "steps.d.ts" + "**/*.ts" ] } From c7874caf9bf92e029317487b9fe54dc972ed12ea Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Fri, 19 Jun 2020 02:51:53 +0300 Subject: [PATCH 18/20] fix --- typings/tests/global-variables.types.ts | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/typings/tests/global-variables.types.ts b/typings/tests/global-variables.types.ts index df3edd3bf..670c0a617 100644 --- a/typings/tests/global-variables.types.ts +++ b/typings/tests/global-variables.types.ts @@ -29,9 +29,22 @@ Scenario('scenario', } ) -// Before(( -// args // $ExpectType string -// ) => {}) -// BeforeSuite() // $ExpectError -// After() // $ExpectError -// AfterSuite() // $ExpectError +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 +}) From 9822a190a4a956d82632a0964b2d654efa6ce360 Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Fri, 19 Jun 2020 10:23:49 +0300 Subject: [PATCH 19/20] fix tests --- lib/helper/WebDriver.js | 7 ------- test/runner/dry_run_test.js | 4 ++-- typings/tests/helpers/WebDriverIO.types.ts | 6 +----- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index 81c933692..05307f041 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -1983,13 +1983,6 @@ class WebDriver extends Helper { }); } - async waitUntilExists(locator, sec = null) { - console.log(`waitUntilExists deprecated: - * use 'waitForElement' to wait for element to be attached - * use 'waitForDetached to wait for element to be removed'`); - return this.waitForStalenessOf(locator, sec); - } - /** * {{> waitInUrl }} */ diff --git a/test/runner/dry_run_test.js b/test/runner/dry_run_test.js index 03a46650d..59cdbf990 100644 --- a/test/runner/dry_run_test.js +++ b/test/runner/dry_run_test.js @@ -5,7 +5,7 @@ const exec = require('child_process').exec; const runner = path.join(__dirname, '/../../bin/codecept.js'); const codecept_dir = path.join(__dirname, '/../data/sandbox'); const codecept_run = `${runner} dry-run`; -const codecept_run_config = config => `${codecept_run} --config ${codecept_dir}/${config}`; +const codecept_run_config = (config, grep) => `${codecept_run} --config ${codecept_dir}/${config} ${grep ? `--grep "${grep}"` : ''}`; const char = require('figures').checkboxOff; describe('dry-run command', () => { @@ -159,7 +159,7 @@ describe('dry-run command', () => { }); it('should work with inject() keyword', (done) => { - exec(`${codecept_run_config('configs/pageObjects/codecept.inject.po.json')} --debug`, (err, stdout) => { + exec(`${codecept_run_config('configs/pageObjects/codecept.inject.po.json', 'check current dir')} --debug`, (err, stdout) => { const lines = stdout.split('\n'); expect(stdout).toContain('injected'); expect(lines).toEqual( diff --git a/typings/tests/helpers/WebDriverIO.types.ts b/typings/tests/helpers/WebDriverIO.types.ts index 994b862ff..f544d38af 100644 --- a/typings/tests/helpers/WebDriverIO.types.ts +++ b/typings/tests/helpers/WebDriverIO.types.ts @@ -290,10 +290,6 @@ wd.waitForClickable() // $ExpectError wd.waitForClickable('div') // $ExpectType void wd.waitForClickable('div', num) // $ExpectType void -wd.waitUntilExists() // $ExpectError -wd.waitUntilExists('div') // $ExpectType void -wd.waitUntilExists('div', num) // $ExpectType void - wd.waitForVisible() // $ExpectError wd.waitForVisible('div') // $ExpectType void wd.waitForVisible('div', num) // $ExpectType void @@ -344,7 +340,7 @@ wd.waitUntil(str) // $ExpectType void wd.waitUntil(str, num, str, num) // $ExpectType void wd.waitUntil(() => {}, num, str, num) // $ExpectType void -wd.switchTo() // $ExpectError +wd.switchTo() // $ExpectType void wd.switchTo('div') // $ExpectType void wd.switchToNextTab(num, num) // $ExpectType void From 0e90a7a25c047db8b373a105fe6615b8006590cd Mon Sep 17 00:00:00 2001 From: Vorobeyko Date: Fri, 19 Jun 2020 11:02:41 +0300 Subject: [PATCH 20/20] fix --- package.json | 4 ++-- test/runner/allure_test.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 62fcb6f91..63700fa13 100644 --- a/package.json +++ b/package.json @@ -23,10 +23,10 @@ }, "files": [ "bin", - "docs", + "docs/**/*.md", "lib", "translations", - "typings" + "typings/**/*.d.ts" ], "main": "lib/index.js", "typings": "typings/index.d.ts", diff --git a/test/runner/allure_test.js b/test/runner/allure_test.js index a65044ada..0af5d87b2 100644 --- a/test/runner/allure_test.js +++ b/test/runner/allure_test.js @@ -77,13 +77,13 @@ describe('CodeceptJS Allure Plugin', function () { it('should report skipped features', (done) => { exec(codecept_run_config('skipped_feature.conf.js'), (err, stdout) => { - stdout.should.include('OK | 0 passed, 2 skipped'); + expect(stdout).toContain('OK | 0 passed, 2 skipped'); const files = fs.readdirSync(path.join(codecept_dir, 'output/skipped')); const reports = files.map((testResultPath) => { - assert(testResultPath.match(/\.xml$/), 'not a xml file'); + expect(testResultPath.match(/\.xml$/)).toBeTruthy(); return fs.readFileSync(path.join(codecept_dir, 'output/skipped', testResultPath), 'utf8'); }).join(' '); - reports.should.include('Skipped due to "skip" on Feature.'); + expect(reports).toContain('Skipped due to "skip" on Feature.'); done(); }); });