You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/CustomServices.md
+19-8Lines changed: 19 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,9 @@ id: customservices
3
3
title: Custom Services
4
4
---
5
5
6
-
You can write your own custom service for the WDIO test runner to custom-fit your needs.
6
+
You can write your own custom service for the WDIO test runner to custom-fit your needs.
7
7
8
-
<dfn>Services</dfn> are add-ons that are created for reusable logic to simplify tests, manage your test suite, and integrate results. Services have access to all the same [`before`/`after` hooks](ConfigurationFile.md) available in the `wdio.conf.js`.
8
+
<dfn>Services</dfn> are add-ons that are created for reusable logic to simplify tests, manage your test suite, and integrate results. Services have access to all the same [`before`/`after` hooks](ConfigurationFile.md) available in the `wdio.conf.js`.
9
9
10
10
The basic construction of a custom service should look like this:
11
11
@@ -23,7 +23,7 @@ export default class CustomService {
23
23
}
24
24
```
25
25
26
-
The only thing to do now in order to use this service is to assign it to the `services` property.
26
+
The only thing to do now in order to use this service is to assign it to the `services` property.
27
27
28
28
Modify your `wdio.conf.js` file to look like this:
29
29
@@ -32,9 +32,20 @@ import CustomService from './service/my.custom.service'
32
32
33
33
exports.config= {
34
34
// ...
35
-
services: [[CustomService, {
36
-
someOption:true
37
-
}]],
35
+
services: [
36
+
/**
37
+
* use imported service class
38
+
*/
39
+
[CustomService, {
40
+
someOption:true
41
+
}],
42
+
/**
43
+
* use absolute path to service
44
+
*/
45
+
['/path/to/service.js', {
46
+
someOption:true
47
+
}]
48
+
],
38
49
// ...
39
50
}
40
51
```
@@ -60,13 +71,13 @@ exports.config = {
60
71
```
61
72
62
73
> **Note:** Services that are added by name behave slightly differently compared to your own imported services. Instead of the service handling all the hooks, as in the example above, the service needs to export a launcher that handles `onPrepare` and `onComplete`. The rest of the hooks will be handled by the service (the default export), as normal.
0 commit comments