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
This commit is contained in:
Nikolai Orekhov
2018-01-03 06:36:22 +05:00
committed by Mohamed Hegazy
parent 6449d48de9
commit 5b310b110f
4 changed files with 85 additions and 0 deletions

View File

@@ -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();

24
types/chai-webdriverio/index.d.ts vendored Normal file
View File

@@ -0,0 +1,24 @@
// Type definitions for chai-webdriverio 0.4
// Project: https://github.com/marcodejongh/chai-webdriverio
// Definitions by: Nikolai Orekhov <https://github.com/sherlock1982>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="webdriverio" />
/// <reference types="chai" />
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<void>, options?: any): (chai: any, utils: any) => void;
export = chaiWebdriverIO;
}

View File

@@ -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"
]
}

View File

@@ -0,0 +1,7 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-single-declare-module" : false,
"no-declare-current-package": false
}
}