@@ -38,14 +38,6 @@ exports.config = {
38
38
};
39
39
```
40
40
41
- An example of using the 'ngHint' plugin is shown below.
42
-
43
- ``` javascript
44
- plugins: [{
45
- path: ' node_modules/protractor/plugins/ngHint' ,
46
- }]
47
- ```
48
-
49
41
If your plugin is a node module, you may use it with the ` package ` option. For
50
42
example, if you did ` npm install example-protractor-plugin ` your config would
51
43
look like:
@@ -56,8 +48,8 @@ look like:
56
48
}]
57
49
```
58
50
59
- Finally, if you are writing a small plugin which will only be used by one config
60
- file, you can write the plugin inline into the config:
51
+ If you are writing a small plugin which will only be used by one config file,
52
+ you can write the plugin inline into the config:
61
53
62
54
``` javascript
63
55
plugins: [{
@@ -69,253 +61,25 @@ file, you can write the plugin inline into the config:
69
61
}]
70
62
```
71
63
64
+ When using plugins, you should specify exactly one of ` path ` , ` package ` , or
65
+ ` inline ` .
66
+
72
67
Writing Plugins
73
68
---------------
74
69
75
70
Plugins are designed to work with any test framework (Jasmine, Mocha, etc),
76
71
so they use generic hooks which Protractor provides. Plugins may change
77
72
the output of Protractor by returning a results object.
78
73
79
- Plugins are node modules which export an object with the following API:
80
-
81
- ``` js
82
- /**
83
- * Sets up plugins before tests are run. This is called after the WebDriver
84
- * session has been started, but before the test framework has been set up.
85
- *
86
- * @this {Object} bound to module.exports
87
- *
88
- * @throws {*} If this function throws an error, a failed assertion is added to
89
- * the test results.
90
- *
91
- * @return {q.Promise=} Can return a promise, in which case protractor will wait
92
- * for the promise to resolve before continuing. If the promise is
93
- * rejected, a failed assertion is added to the test results.
94
- */
95
- exports .setup = function () {};
96
-
97
- /**
98
- * This is called before the test have been run but after the test framework has
99
- * been set up. Analogous to a config file's `onPreare`.
100
- *
101
- * Very similar to using `setup`, but allows you to access framework-specific
102
- * variables/funtions (e.g. `jasmine.getEnv().addReporter()`)
103
- *
104
- * @throws {*} If this function throws an error, a failed assertion is added to
105
- * the test results.
106
- *
107
- * @return {Q.Promise=} Can return a promise, in which case protractor will wait
108
- * for the promise to resolve before continuing. If the promise is
109
- * rejected, a failed assertion is added to the test results.
110
- */
111
- exports .onPrepare = function () {};
112
-
113
- /**
114
- * This is called after the tests have been run, but before the WebDriver
115
- * session has been terminated.
116
- *
117
- * @this {Object} bound to module.exports
118
- *
119
- * @throws {*} If this function throws an error, a failed assertion is added to
120
- * the test results.
121
- *
122
- * @return {q.Promise=} Can return a promise, in which case protractor will wait
123
- * for the promise to resolve before continuing. If the promise is
124
- * rejected, a failed assertion is added to the test results.
125
- */
126
- exports .teardown = function () {};
127
-
128
- /**
129
- * Called after the test results have been finalized and any jobs have been
130
- * updated (if applicable).
131
- *
132
- * @this {Object} bound to module.exports
133
- *
134
- * @throws {*} If this function throws an error, it is outputted to the console
135
- *
136
- * @return {q.Promise=} Can return a promise, in which case protractor will wait
137
- * for the promise to resolve before continuing. If the promise is
138
- * rejected, an error is logged to the console.
139
- */
140
- exports .postResults = function () {};
141
-
142
- /**
143
- * Called after each test block (in Jasmine, this means an `it` block)
144
- * completes.
145
- *
146
- * @param {boolean} passed True if the test passed.
147
- * @param {Object} testInfo information about the test which just ran.
148
- *
149
- * @this {Object} bound to module.exports
150
- *
151
- * @throws {*} If this function throws an error, a failed assertion is added to
152
- * the test results.
153
- *
154
- * @return {q.Promise=} Can return a promise, in which case protractor will wait
155
- * for the promise to resolve before outputting test results. Protractor
156
- * will *not* wait before executing the next test, however. If the promise
157
- * is rejected, a failed assertion is added to the test results.
158
- */
159
- exports .postTest = function (passed , testInfo ) {};
160
-
161
- /**
162
- * This is called inside browser.get() directly after the page loads, and before
163
- * angular bootstraps.
164
- *
165
- * @this {Object} bound to module.exports
166
- *
167
- * @throws {*} If this function throws an error, a failed assertion is added to
168
- * the test results.
169
- *
170
- * @return {q.Promise=} Can return a promise, in which case protractor will wait
171
- * for the promise to resolve before continuing. If the promise is
172
- * rejected, a failed assertion is added to the test results.
173
- */
174
- exports .onPageLoad = function () {};
175
-
176
- /**
177
- * This is called inside browser.get() directly after angular is done
178
- * bootstrapping/synchronizing. If browser.ignoreSynchronization is true, this
179
- * will not be called.
180
- *
181
- * @this {Object} bound to module.exports
182
- *
183
- * @throws {*} If this function throws an error, a failed assertion is added to
184
- * the test results.
185
- *
186
- * @return {q.Promise=} Can return a promise, in which case protractor will wait
187
- * for the promise to resolve before continuing. If the promise is
188
- * rejected, a failed assertion is added to the test results.
189
- */
190
- exports .onPageStable = function () {};
191
-
192
- /**
193
- * Between every webdriver action, Protractor calls browser.waitForAngular() to
194
- * make sure that Angular has no outstanding $http or $timeout calls.
195
- * You can use waitForPromise() to have Protractor additionally wait for your
196
- * custom promise to be resolved inside of browser.waitForAngular().
197
- *
198
- * @this {Object} bound to module.exports
199
- *
200
- * @throws {*} If this function throws an error, a failed assertion is added to
201
- * the test results.
202
- *
203
- * @return {q.Promise=} Can return a promise, in which case protractor will wait
204
- * for the promise to resolve before continuing. If the promise is
205
- * rejected, a failed assertion is added to the test results, and protractor
206
- * will continue onto the next command. If nothing is returned or something
207
- * other than a promise is returned, protractor will continue onto the next
208
- * command.
209
- */
210
- exports .waitForPromise = function () {};
211
-
212
- /**
213
- * Between every webdriver action, Protractor calls browser.waitForAngular() to
214
- * make sure that Angular has no outstanding $http or $timeout calls.
215
- * You can use waitForCondition() to have Protractor additionally wait for your
216
- * custom condition to be truthy.
217
- *
218
- * @this {Object} bound to module.exports
219
- *
220
- * @throws {*} If this function throws an error, a failed assertion is added to
221
- * the test results.
222
- *
223
- * @return {q.Promise<boolean>|boolean} If truthy, Protractor will continue onto
224
- * the next command. If falsy, webdriver will continuously re-run this
225
- * function until it is truthy. If a rejected promise is returned, a failed
226
- * assertion is added to the test results, and protractor will continue onto
227
- * the next command.
228
- */
229
- exports .waitForCondition = function () {};
230
-
231
- /**
232
- * Used when reporting results.
233
- *
234
- * If you do not specify this property, it will be filled in with something
235
- * reasonable (e.g. the plugin's path)
236
- *
237
- * @type {string}
238
- */
239
- exports .name = ' ' ;
240
-
241
-
242
- /**
243
- * Used to turn off default checks for angular stability
244
- *
245
- * Normally Protractor waits for all $timeout and $http calls to be processed
246
- * before executing the next command. This can be disabled using
247
- * browser.ignoreSynchronization, but that will also disable any
248
- * <Plugin>.waitForPromise or <Plugin>.waitForCondition checks. If you want to
249
- * disable synchronization with angular, but leave in tact any custom plugin
250
- * synchronization, this is the option for you.
251
- *
252
- * This is used by users who want to replace Protractor's synchronization code
253
- * with their own.
254
- *
255
- * @type {boolean}
256
- */
257
- exports .skipAngularStability
258
- ```
259
-
260
- Each of these exported properties are optional.
74
+ Plugins are node modules that export an object implementing the
75
+ ` ProtractorPlugin ` interface. Please see [ ` /lib/plugins.ts ` ] (
76
+ /lib/plugins.ts#L25) for a list of hooks that are available to plugins.
261
77
262
- ### Provided properties and functions
78
+ ##### Provided properties and functions
263
79
264
80
Extra properties are added to your ` module.exports ` when Protractor loads your
265
81
plugin. These allow your plugin to do things like access its configuration
266
- block or add test results. They are as follows:
267
-
268
- ``` js
269
- /**
270
- * The plugin configuration object. Note that this is not the entire
271
- * Protractor config object, just the entry in the plugins array for this
272
- * plugin.
273
- *
274
- * @type {Object}
275
- */
276
- exports .config ;
277
-
278
- /**
279
- * Adds a failed assertion to the test's results.
280
- *
281
- * @param {string} message The error message for the failed assertion
282
- * @param {specName: string, stackTrace: string} options Some optional extra
283
- * information about the assertion:
284
- * - specName The name of the spec which this assertion belongs to.
285
- * Defaults to `PLUGIN_NAME + ' Plugin Tests'`.
286
- * - stackTrace The stack trace for the failure. Defaults to undefined.
287
- * Defaults to `{}`.
288
- *
289
- * @throws {Error} Throws an error if called after results have been reported
290
- */
291
- exports .addFailure (message, options);
292
-
293
- /**
294
- * Adds a passed assertion to the test's results.
295
- *
296
- * @param {specName: string} options Extra information about the assertion:
297
- * - specName The name of the spec which this assertion belongs to.
298
- * Defaults to `PLUGIN_NAME + ' Plugin Tests'`.
299
- * Defaults to `{}`.
300
- *
301
- * @throws {Error} Throws an error if called after results have been reported
302
- */
303
- exports .addSuccess (options);
304
-
305
- /**
306
- * Warns the user that something is problematic.
307
- *
308
- * @param {string} message The message to warn the user about
309
- * @param {specName: string} options Extra information about the assertion:
310
- * - specName The name of the spec which this assertion belongs to.
311
- * Defaults to `PLUGIN_NAME + ' Plugin Tests'`.
312
- * Defaults to `{}`.
313
- */
314
- exports .addWarning (message, options);
315
- ```
316
-
317
- If you specify any of these properties in your plugin file, they will be
318
- overwritten.
82
+ block or add test results. See ` /lib/plugins.ts ` for the full list.
319
83
320
84
### Writing Plugins in TypeScript
321
85
@@ -372,15 +136,6 @@ First Party Plugins
372
136
github repo [ angular/protractor-timeline-plugin]
373
137
(https://github.com/angular/protractor-timeline-plugin ).
374
138
375
- * ngHint Plugin
376
-
377
- The ngHint plugin uses [ Angular Hint] ( https://github.com/angular/angular-hint )
378
- to generate run-time hinting and then turns these hints into Protractor tests.
379
- It is published at the npm module [ ` protractor-ng-hint-plugin ` ]
380
- (https://www.npmjs.com/package/protractor-ng-hint-plugin ) and stored at the
381
- github repo [ angular/protractor-ng-hint-plugin]
382
- (https://github.com/angular/protractor-ng-hint-plugin ).
383
-
384
139
* Console Plugin (Chrome Only)
385
140
386
141
The console plugin checks the browser log after each test for warnings and
@@ -389,6 +144,15 @@ First Party Plugins
389
144
github repo [ angular/protractor-console-plugin]
390
145
(https://github.com/angular/protractor-console-plugin ).
391
146
147
+ * ngHint Plugin (NOT MAINTAINED)
148
+
149
+ The ngHint plugin uses [ Angular Hint] ( https://github.com/angular/angular-hint )
150
+ to generate run-time hinting and then turns these hints into Protractor tests.
151
+ It is published at the npm module [ ` protractor-ng-hint-plugin ` ]
152
+ (https://www.npmjs.com/package/protractor-ng-hint-plugin ) and stored at the
153
+ github repo [ angular/protractor-ng-hint-plugin]
154
+ (https://github.com/angular/protractor-ng-hint-plugin ).
155
+
392
156
Community Plugins
393
157
-----------------
394
158
0 commit comments