From 5b310b110feb2ab3b390dbb54a68eced9864bb60 Mon Sep 17 00:00:00 2001 From: Nikolai Orekhov Date: Wed, 3 Jan 2018 06:36:22 +0500 Subject: [PATCH] add types for chai-webdriverio (#21891) * add types for chai-webdriverio * fix lint warning and remove extra lint rules * fix compilation * added types from webdriverio * try to fix build * try to fix build --- .../chai-webdriverio-tests.ts | 30 +++++++++++++++++++ types/chai-webdriverio/index.d.ts | 24 +++++++++++++++ types/chai-webdriverio/tsconfig.json | 24 +++++++++++++++ types/chai-webdriverio/tslint.json | 7 +++++ 4 files changed, 85 insertions(+) create mode 100644 types/chai-webdriverio/chai-webdriverio-tests.ts create mode 100644 types/chai-webdriverio/index.d.ts create mode 100644 types/chai-webdriverio/tsconfig.json create mode 100644 types/chai-webdriverio/tslint.json diff --git a/types/chai-webdriverio/chai-webdriverio-tests.ts b/types/chai-webdriverio/chai-webdriverio-tests.ts new file mode 100644 index 0000000000..989eb64960 --- /dev/null +++ b/types/chai-webdriverio/chai-webdriverio-tests.ts @@ -0,0 +1,30 @@ +import chai = require('chai'); +import webdriverio = require('webdriverio'); +import chaiWebdriverio = require('chai-webdriverio'); + +const options = { + desiredCapabilities: { + browserName: 'firefox' + } +}; + +const browser = webdriverio.remote(options); +chai.use(chaiWebdriverio(browser)); + +const selector = 'Hello, World!'; + +chai.expect(selector).to.be.there(); + +chai.expect(selector).to.be.visible(); + +chai.expect(selector).to.have.text(selector); + +chai.expect(selector).to.have.text(/regex/); + +chai.expect(selector).to.have.count(10); + +chai.expect(selector).to.have.value('x'); + +chai.expect(selector).to.have.value(/regex/); + +chai.expect(selector).to.have.focus(); diff --git a/types/chai-webdriverio/index.d.ts b/types/chai-webdriverio/index.d.ts new file mode 100644 index 0000000000..d0b958dad5 --- /dev/null +++ b/types/chai-webdriverio/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for chai-webdriverio 0.4 +// Project: https://github.com/marcodejongh/chai-webdriverio +// Definitions by: Nikolai Orekhov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare namespace Chai { + interface Assertion { + count: (count: number) => void; + focus: () => void; + text: (expected: string|number|RegExp) => void; + there: () => void; + value: (expected: string|number|RegExp) => void; + visible: () => void; + immediately: Assertion; + } +} + +declare module 'chai-webdriverio' { + function chaiWebdriverIO(client: WebdriverIO.Client, options?: any): (chai: any, utils: any) => void; + export = chaiWebdriverIO; +} diff --git a/types/chai-webdriverio/tsconfig.json b/types/chai-webdriverio/tsconfig.json new file mode 100644 index 0000000000..c44958af89 --- /dev/null +++ b/types/chai-webdriverio/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "chai-webdriverio-tests.ts" + ] +} \ No newline at end of file diff --git a/types/chai-webdriverio/tslint.json b/types/chai-webdriverio/tslint.json new file mode 100644 index 0000000000..1be28efd2f --- /dev/null +++ b/types/chai-webdriverio/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-single-declare-module" : false, + "no-declare-current-package": false + } +}