@@ -18,16 +18,217 @@ export interface PluginConfig {
18
18
[ key : string ] : any ;
19
19
}
20
20
21
- export class ProtractorPlugin {
22
- skipAngularStability : boolean ;
21
+ export interface ProtractorPlugin {
22
+ /**
23
+ * Sets up plugins before tests are run. This is called after the WebDriver
24
+ * session has been started, but before the test framework has been set up.
25
+ *
26
+ * @this {Object} bound to module.exports
27
+ *
28
+ * @throws {* } If this function throws an error, a failed assertion is added to
29
+ * the test results.
30
+ *
31
+ * @return {q.Promise= } Can return a promise, in which case protractor will wait
32
+ * for the promise to resolve before continuing. If the promise is
33
+ * rejected, a failed assertion is added to the test results.
34
+ */
35
+ setup ?: ( ) => q . Promise < any > ;
36
+
37
+ /**
38
+ * This is called after the tests have been run, but before the WebDriver
39
+ * session has been terminated.
40
+ *
41
+ * @this {Object} bound to module.exports
42
+ *
43
+ * @throws {* } If this function throws an error, a failed assertion is added to
44
+ * the test results.
45
+ *
46
+ * @return {q.Promise= } Can return a promise, in which case protractor will wait
47
+ * for the promise to resolve before continuing. If the promise is
48
+ * rejected, a failed assertion is added to the test results.
49
+ */
50
+ teardown ?: ( ) => q . Promise < any > ;
51
+
52
+ /**
53
+ * Called after the test results have been finalized and any jobs have been
54
+ * updated (if applicable).
55
+ *
56
+ * @this {Object} bound to module.exports
57
+ *
58
+ * @throws {* } If this function throws an error, it is outputted to the console
59
+ *
60
+ * @return {q.Promise= } Can return a promise, in which case protractor will wait
61
+ * for the promise to resolve before continuing. If the promise is
62
+ * rejected, an error is logged to the console.
63
+ */
64
+ postResults ?: ( ) => q . Promise < any > ;
23
65
24
- name : string ;
25
- config : PluginConfig ;
26
- addFailure :
66
+ /**
67
+ * Called after each test block (in Jasmine, this means an `it` block)
68
+ * completes.
69
+ *
70
+ * @param {boolean } passed True if the test passed.
71
+ * @param {Object } testInfo information about the test which just ran.
72
+ *
73
+ * @this {Object} bound to module.exports
74
+ *
75
+ * @throws {* } If this function throws an error, a failed assertion is added to
76
+ * the test results.
77
+ *
78
+ * @return {q.Promise= } Can return a promise, in which case protractor will wait
79
+ * for the promise to resolve before outputting test results. Protractor
80
+ * will *not* wait before executing the next test, however. If the promise
81
+ * is rejected, a failed assertion is added to the test results.
82
+ */
83
+ postTest ?: ( passed : boolean , testInfo : any ) => q . Promise < any > ;
84
+
85
+ /**
86
+ * This is called inside browser.get() directly after the page loads, and before
87
+ * angular bootstraps.
88
+ *
89
+ * @this {Object} bound to module.exports
90
+ *
91
+ * @throws {* } If this function throws an error, a failed assertion is added to
92
+ * the test results.
93
+ *
94
+ * @return {q.Promise= } Can return a promise, in which case protractor will wait
95
+ * for the promise to resolve before continuing. If the promise is
96
+ * rejected, a failed assertion is added to the test results.
97
+ */
98
+ onPageLoad ?: ( ) => q . Promise < any > ;
99
+
100
+ /**
101
+ * This is called inside browser.get() directly after angular is done
102
+ * bootstrapping/synchronizing. If browser.ignoreSynchronization is true, this
103
+ * will not be called.
104
+ *
105
+ * @this {Object} bound to module.exports
106
+ *
107
+ * @throws {* } If this function throws an error, a failed assertion is added to
108
+ * the test results.
109
+ *
110
+ * @return {q.Promise= } Can return a promise, in which case protractor will wait
111
+ * for the promise to resolve before continuing. If the promise is
112
+ * rejected, a failed assertion is added to the test results.
113
+ */
114
+ onPageStable ?: ( ) => q . Promise < any > ;
115
+
116
+ /**
117
+ * Between every webdriver action, Protractor calls browser.waitForAngular() to
118
+ * make sure that Angular has no outstanding $http or $timeout calls.
119
+ * You can use waitForPromise() to have Protractor additionally wait for your
120
+ * custom promise to be resolved inside of browser.waitForAngular().
121
+ *
122
+ * @this {Object} bound to module.exports
123
+ *
124
+ * @throws {* } If this function throws an error, a failed assertion is added to
125
+ * the test results.
126
+ *
127
+ * @return {q.Promise= } Can return a promise, in which case protractor will wait
128
+ * for the promise to resolve before continuing. If the promise is
129
+ * rejected, a failed assertion is added to the test results, and protractor
130
+ * will continue onto the next command. If nothing is returned or something
131
+ * other than a promise is returned, protractor will continue onto the next
132
+ * command.
133
+ */
134
+ waitForPromise ?: ( ) => q . Promise < any > ;
135
+
136
+ /**
137
+ * Between every webdriver action, Protractor calls browser.waitForAngular() to
138
+ * make sure that Angular has no outstanding $http or $timeout calls.
139
+ * You can use waitForCondition() to have Protractor additionally wait for your
140
+ * custom condition to be truthy.
141
+ *
142
+ * @this {Object} bound to module.exports
143
+ *
144
+ * @throws {* } If this function throws an error, a failed assertion is added to
145
+ * the test results.
146
+ *
147
+ * @return {q.Promise<boolean>|boolean } If truthy, Protractor will continue onto
148
+ * the next command. If falsy, webdriver will continuously re-run this
149
+ * function until it is truthy. If a rejected promise is returned, a failed
150
+ * assertion is added to the test results, and protractor will continue onto
151
+ * the next command.
152
+ */
153
+ waitForCondition ?: ( ) => q . Promise < any > ;
154
+
155
+ /**
156
+ * Used to turn off default checks for angular stability
157
+ *
158
+ * Normally Protractor waits for all $timeout and $http calls to be processed
159
+ * before executing the next command. This can be disabled using
160
+ * browser.ignoreSynchronization, but that will also disable any
161
+ * <Plugin>.waitForPromise or <Plugin>.waitForCondition checks. If you want
162
+ * to
163
+ * disable synchronization with angular, but leave in tact any custom plugin
164
+ * synchronization, this is the option for you.
165
+ *
166
+ * This is used by users who want to replace Protractor's synchronization code
167
+ * This is used by users who want to replace Protractor's synchronization code
168
+ * with their own.
169
+ *
170
+ * @type {boolean }
171
+ */
172
+ skipAngularStability ?: boolean ;
173
+
174
+ /**
175
+ * Used when reporting results.
176
+ *
177
+ * If you do not specify this property, it will be filled in with something
178
+ * reasonable (e.g. the plugin's path)
179
+ *
180
+ * @type {string }
181
+ */
182
+ name ?: string ;
183
+
184
+ /**
185
+ * The plugin configuration object. Note that this is not the entire
186
+ * Protractor config object, just the entry in the plugins array for this
187
+ * plugin.
188
+ *
189
+ * @type {Object }
190
+ */
191
+ config ?: PluginConfig ;
192
+
193
+ /**
194
+ * Adds a failed assertion to the test's results.
195
+ *
196
+ * @param {string } message The error message for the failed assertion
197
+ * @param {specName: string, stackTrace: string } options Some optional extra
198
+ * information about the assertion:
199
+ * - specName The name of the spec which this assertion belongs to.
200
+ * Defaults to `PLUGIN_NAME + ' Plugin Tests'`.
201
+ * - stackTrace The stack trace for the failure. Defaults to undefined.
202
+ * Defaults to `{}`.
203
+ *
204
+ * @throws {Error } Throws an error if called after results have been reported
205
+ */
206
+ addFailure ?:
27
207
( message ?: string ,
28
208
info ?: { specName ?: string , stackTrace ?: string } ) => void ;
29
- addSuccess : ( info ?: { specName ?: string } ) => void ;
30
- addWarning : ( message ?: string , info ?: { specName ?: string } ) => void ;
209
+
210
+ /**
211
+ * Adds a passed assertion to the test's results.
212
+ *
213
+ * @param {specName: string } options Extra information about the assertion:
214
+ * - specName The name of the spec which this assertion belongs to.
215
+ * Defaults to `PLUGIN_NAME + ' Plugin Tests'`.
216
+ * Defaults to `{}`.
217
+ *
218
+ * @throws {Error } Throws an error if called after results have been reported
219
+ */
220
+ addSuccess ?: ( info ?: { specName ?: string } ) => void ;
221
+
222
+ /**
223
+ * Warns the user that something is problematic.
224
+ *
225
+ * @param {string } message The message to warn the user about
226
+ * @param {specName: string } options Extra information about the assertion:
227
+ * - specName The name of the spec which this assertion belongs to.
228
+ * Defaults to `PLUGIN_NAME + ' Plugin Tests'`.
229
+ * Defaults to `{}`.
230
+ */
231
+ addWarning ?: ( message ?: string , info ?: { specName ?: string } ) => void ;
31
232
}
32
233
33
234
/**
0 commit comments