Add selenium-standalone typings.

This commit is contained in:
Sander de Waal
2018-06-15 13:24:04 +02:00
parent 56265d81d4
commit c2d6986ec6
4 changed files with 199 additions and 0 deletions
+80
View File
@@ -0,0 +1,80 @@
// Type definitions for selenium-standalone 6.15
// Project: https://github.com/vvo/selenium-standalone
// Definitions by: Sander de Waal <https://github.com/SanderDeWaal1992>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import * as http from "http";
import { URL } from "url";
import { ChildProcess, SpawnOptions } from "child_process";
export function install(cb: (error: Error | undefined, fsPaths: FsPaths) => void): void;
export function install(opts: InstallOpts, cb: (error: Error | undefined, fsPaths: FsPaths) => void): void;
export function install(optsCb: InstallOpts | ((error: Error | undefined, fsPaths: FsPaths) => void), cb?: (error: Error | undefined, fsPaths: FsPaths) => void): void;
export function start(cb: (error: Error | null, selenium: ChildProcess) => void): void;
export function start(opts: StartOpts, cb: (error: Error | null, selenium: ChildProcess) => void): void;
export function start(optsCb: StartOpts | ((error: Error | null, selenium: ChildProcess) => void), cb?: (error: Error | null, selenium: ChildProcess) => void): void;
export interface InstallOpts {
baseURL?: string;
basePath?: string;
version?: string;
drivers?: {
[browser: string]: {
version?: string;
arch: string | "ia32" | "x64";
baseURL: string;
}
};
progressCb?: (totalLength: number, progressLength: number, chunkLength: number) => void;
logger?: (message: string) => void;
requestOpts?: http.RequestOptions | string | URL;
cb?: (error: Error) => void;
}
export interface StartOpts {
basePath?: string;
version?: string;
drivers?: {
[browser: string]: {
version?: string;
arch: string | "ia32" | "x64";
baseURL: string;
}
};
seleniumArgs?: string[];
javaArgs?: string[];
spawnOptions?: SpawnOptions;
spawnCb?: (selenium?: ChildProcess) => void;
javaPath?: string;
requestOpts?: http.RequestOptions | string | URL;
cb?: (error: Error, child: ChildProcess) => void;
}
export interface FsPaths {
[x: string]: any;
chrome?: {
[x: string]: any;
installPath: string;
};
ie?: {
[x: string]: any;
installPath: string;
};
edge?: {
[x: string]: any;
installPath: string;
};
firefox?: {
[x: string]: any;
installPath: string;
};
selenium?: {
[x: string]: any;
installPath: string;
};
}
export { ChildProcess, SpawnOptions } from "child_process";
@@ -0,0 +1,95 @@
"use strict";
import { install, start, ChildProcess, FsPaths, InstallOpts, StartOpts } from "selenium-standalone";
// InstallOpts interface
let installOpts: InstallOpts = {
baseURL: "baseURL",
basePath: "basePath",
version: "version",
drivers: {
chrome: {
version: "chrome_version",
arch: "ia32",
baseURL: "baseURL a",
},
firefox: {
version: "version",
arch: "ia64",
baseURL: "baseURL b",
}
},
progressCb: (totalLength: number, progressLength: number, chunkLength: number) => {},
logger: (message: string) => {},
requestOpts: "requestOpts",
cb: (error: Error) => {},
};
installOpts = {};
installOpts = {
requestOpts: {
agent: true,
host: "host",
family: 5
},
};
// StartOpts interface
let startOpts: StartOpts = {
basePath: "basePath",
version: "version",
drivers: {
chrome: {
version: "chrome_version",
arch: "ia32",
baseURL: "baseURL a",
},
firefox: {
version: "version",
arch: "ia64",
baseURL: "baseURL b",
}
},
seleniumArgs: ["bla", "foo"],
javaArgs: ["bla", "foo"],
spawnOptions: {},
spawnCb: (selenium?: ChildProcess) => {},
javaPath: "javaPath",
requestOpts: "requestOpts",
cb: (error: Error, child: ChildProcess) => {},
};
startOpts = {};
// FsPaths interface
let fsPaths: FsPaths = {
bla: "foo",
chrome: {
installPath: "installPath",
bla: "foo",
},
ie: {
installPath: "installPath",
bla: "foo",
},
edge: {
installPath: "installPath",
bla: "foo",
},
firefox: {
installPath: "installPath",
bla: "foo",
},
selenium: {
installPath: "installPath",
bla: "foo",
},
};
fsPaths = {};
// start method
start(startOpts, (error: Error | null, selenium: ChildProcess) => {});
start((error: Error | null, selenium: ChildProcess) => {});
// install method
install(installOpts, (error: Error | undefined, fsPaths: FsPaths) => {});
install((error: Error | undefined, fsPaths: FsPaths) => {});
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"selenium-standalone-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }