Skip to content

Commit e6b8d6e

Browse files
sjelinigniteram
authored andcommitted
chore(types): better types for ProtractorPlugin (angular#4034)
1 parent f8ade20 commit e6b8d6e

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

lib/plugins.ts

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ export interface ProtractorPlugin {
3030
* @throws {*} If this function throws an error, a failed assertion is added to
3131
* the test results.
3232
*
33-
* @return {Q.Promise=} Can return a promise, in which case protractor will wait
33+
* @return {Promise=} Can return a promise, in which case protractor will wait
3434
* for the promise to resolve before continuing. If the promise is
3535
* rejected, a failed assertion is added to the test results.
3636
*/
37-
setup?: () => q.Promise<any>;
37+
setup?(): void|Promise<void>;
3838

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

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

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

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

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

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

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

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

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

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

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

253254
/**

0 commit comments

Comments
 (0)