Add type for asynchronous nightwatch test hooks

This commit is contained in:
Daniel Faust
2017-12-07 10:51:47 +01:00
parent 67e6191912
commit f6329dabb0
2 changed files with 15 additions and 5 deletions
+12 -5
View File
@@ -2160,16 +2160,23 @@ export interface NightwatchCustomAssertions {}
export interface NightwatchBrowser extends NightwatchAPI, NightwatchCustomCommands, NightwatchCustomAssertions, NightwatchCustomPageObjects { }
/**
* Performs an assertion
*
*/
export type NightwatchTest = (browser: NightwatchBrowser) => void;
export interface NightwatchTests {
export interface NightwatchTestFunctions {
[key: string]: NightwatchTest;
}
export type NightwatchTestHook = (browser: NightwatchBrowser, done: () => void) => void;
export interface NightwatchTestHooks {
before?: NightwatchTestHook;
after?: NightwatchTestHook;
beforeEach?: NightwatchTestHook;
afterEach?: NightwatchTestHook;
}
export type NightwatchTests = NightwatchTestFunctions | NightwatchTestHooks;
/**
* Performs an assertion
*
+3
View File
@@ -1,6 +1,9 @@
import { NightwatchAPI, NightwatchTests } from 'nightwatch';
const test: NightwatchTests = {
before: (browser, done) => {
done();
},
'Demo test Google': (browser) => {
browser
.url('http://www.google.com')