Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
chore(types): better types for ProtractorPlugin (#4034)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjelin authored Jan 31, 2017
1 parent b6207ea commit bb535d3
Showing 1 changed file with 36 additions and 35 deletions.
71 changes: 36 additions & 35 deletions lib/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export interface ProtractorPlugin {
* @throws {*} If this function throws an error, a failed assertion is added to
* the test results.
*
* @return {Q.Promise=} Can return a promise, in which case protractor will wait
* @return {Promise=} Can return a promise, in which case protractor will wait
* for the promise to resolve before continuing. If the promise is
* rejected, a failed assertion is added to the test results.
*/
setup?: () => q.Promise<any>;
setup?(): void|Promise<void>;

/**
* This is called before the test have been run but after the test framework has
Expand All @@ -46,11 +46,11 @@ export interface ProtractorPlugin {
* @throws {*} If this function throws an error, a failed assertion is added to
* the test results.
*
* @return {Q.Promise=} Can return a promise, in which case protractor will wait
* @return {Promise=} Can return a promise, in which case protractor will wait
* for the promise to resolve before continuing. If the promise is
* rejected, a failed assertion is added to the test results.
*/
onPrepare?: () => q.Promise<any>;
onPrepare?(): void|Promise<void>;

/**
* This is called after the tests have been run, but before the WebDriver
Expand All @@ -61,11 +61,11 @@ export interface ProtractorPlugin {
* @throws {*} If this function throws an error, a failed assertion is added to
* the test results.
*
* @return {Q.Promise=} Can return a promise, in which case protractor will wait
* @return {Promise=} Can return a promise, in which case protractor will wait
* for the promise to resolve before continuing. If the promise is
* rejected, a failed assertion is added to the test results.
*/
teardown?: () => q.Promise<any>;
teardown?(): void|Promise<void>;

/**
* Called after the test results have been finalized and any jobs have been
Expand All @@ -75,11 +75,11 @@ export interface ProtractorPlugin {
*
* @throws {*} If this function throws an error, it is outputted to the console
*
* @return {Q.Promise=} Can return a promise, in which case protractor will wait
* @return {Promise=} Can return a promise, in which case protractor will wait
* for the promise to resolve before continuing. If the promise is
* rejected, an error is logged to the console.
*/
postResults?: () => q.Promise<any>;
postResults?(): void|Promise<void>;

/**
* Called after each test block (in Jasmine, this means an `it` block)
Expand All @@ -93,12 +93,12 @@ export interface ProtractorPlugin {
* @throws {*} If this function throws an error, a failed assertion is added to
* the test results.
*
* @return {Q.Promise=} Can return a promise, in which case protractor will wait
* @return {Promise=} Can return a promise, in which case protractor will wait
* for the promise to resolve before outputting test results. Protractor
* will *not* wait before executing the next test, however. If the promise
* is rejected, a failed assertion is added to the test results.
*/
postTest?: (passed: boolean, testInfo: any) => q.Promise<any>;
postTest?(passed: boolean, testInfo: any): void|Promise<void>;

/**
* This is called inside browser.get() directly after the page loads, and before
Expand All @@ -109,11 +109,11 @@ export interface ProtractorPlugin {
* @throws {*} If this function throws an error, a failed assertion is added to
* the test results.
*
* @return {Q.Promise=} Can return a promise, in which case protractor will wait
* for the promise to resolve before continuing. If the promise is
* rejected, a failed assertion is added to the test results.
* @return {webdriver.promise.Promise=} Can return a promise, in which case
* protractor will wait for the promise to resolve before continuing. If
* the promise is rejected, a failed assertion is added to the test results.
*/
onPageLoad?: () => q.Promise<any>;
onPageLoad?(): void|webdriver.promise.Promise<void>;

/**
* This is called inside browser.get() directly after angular is done
Expand All @@ -125,11 +125,11 @@ export interface ProtractorPlugin {
* @throws {*} If this function throws an error, a failed assertion is added to
* the test results.
*
* @return {Q.Promise=} Can return a promise, in which case protractor will wait
* for the promise to resolve before continuing. If the promise is
* rejected, a failed assertion is added to the test results.
* @return {webdriver.promise.Promise=} Can return a promise, in which case
* protractor will wait for the promise to resolve before continuing. If
* the promise is rejected, a failed assertion is added to the test results.
*/
onPageStable?: () => q.Promise<any>;
onPageStable?(): void|webdriver.promise.Promise<void>;

/**
* Between every webdriver action, Protractor calls browser.waitForAngular() to
Expand All @@ -142,33 +142,34 @@ export interface ProtractorPlugin {
* @throws {*} If this function throws an error, a failed assertion is added to
* the test results.
*
* @return {Q.Promise=} Can return a promise, in which case protractor will wait
* for the promise to resolve before continuing. If the promise is
* rejected, a failed assertion is added to the test results, and protractor
* will continue onto the next command. If nothing is returned or something
* other than a promise is returned, protractor will continue onto the next
* command.
* @return {webdriver.promise.Promise=} Can return a promise, in which case
* protractor will wait for the promise to resolve before continuing. If the
* promise is rejected, a failed assertion is added to the test results, and
* protractor will continue onto the next command. If nothing is returned or
* something other than a promise is returned, protractor will continue
* onto the next command.
*/
waitForPromise?: () => q.Promise<any>;
waitForPromise?(): webdriver.promise.Promise<void>;

/**
* Between every webdriver action, Protractor calls browser.waitForAngular() to
* make sure that Angular has no outstanding $http or $timeout calls.
* You can use waitForCondition() to have Protractor additionally wait for your
* custom condition to be truthy.
* custom condition to be truthy. If specified, this function will be called
* repeatedly until truthy.
*
* @this {Object} bound to module.exports
*
* @throws {*} If this function throws an error, a failed assertion is added to
* the test results.
*
* @return {Q.Promise<boolean>|boolean} If truthy, Protractor will continue onto
* the next command. If falsy, webdriver will continuously re-run this
* function until it is truthy. If a rejected promise is returned, a failed
* assertion is added to the test results, and protractor will continue onto
* the next command.
* @return {webdriver.promise.Promise<boolean>|boolean} If truthy, Protractor
* will continue onto the next command. If falsy, webdriver will
* continuously re-run this function until it is truthy. If a rejected promise
* is returned, a failed assertion is added to the test results, and Protractor
* will continue onto the next command.
*/
waitForCondition?: () => q.Promise<any>;
waitForCondition?(): webdriver.promise.Promise<boolean>|boolean;

/**
* Used to turn off default checks for angular stability
Expand Down Expand Up @@ -222,7 +223,7 @@ export interface ProtractorPlugin {
*
* @throws {Error} Throws an error if called after results have been reported
*/
addFailure?: (message?: string, info?: {specName?: string, stackTrace?: string}) => void;
addFailure?(message?: string, info?: {specName?: string, stackTrace?: string}): void;

/**
* Adds a passed assertion to the test's results. Note: this is added by the
Expand All @@ -235,7 +236,7 @@ export interface ProtractorPlugin {
*
* @throws {Error} Throws an error if called after results have been reported
*/
addSuccess?: (info?: {specName?: string}) => void;
addSuccess?(info?: {specName?: string}): void;

/**
* Warns the user that something is problematic. Note: this is added by the
Expand All @@ -247,7 +248,7 @@ export interface ProtractorPlugin {
* Defaults to `PLUGIN_NAME + ' Plugin Tests'`.
* Defaults to `{}`.
*/
addWarning?: (message?: string, info?: {specName?: string}) => void;
addWarning?(message?: string, info?: {specName?: string}): void;
}

/**
Expand Down

0 comments on commit bb535d3

Please sign in to comment.