wdio-test-ledger-service 9.2.5 → 9.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -13
- package/package.json +1 -2
- package/src/index.js +11 -9
package/README.md
CHANGED
|
@@ -14,22 +14,35 @@ npm install wdio-test-ledger-service
|
|
|
14
14
|
|
|
15
15
|
## Add the service to the services array in wdio.conf.js
|
|
16
16
|
|
|
17
|
-
```
|
|
17
|
+
```javascript
|
|
18
18
|
services: [['test-ledger', {
|
|
19
|
-
reporterOutputDir :
|
|
20
|
-
apiUrl :
|
|
21
|
-
|
|
22
|
-
apiToken : `12345`, // Found in the app.testledger.dev under your proifle section
|
|
19
|
+
reporterOutputDir : './testledger', // This must match the outputDir from the wdio-test-reporter
|
|
20
|
+
apiUrl : 'app-api.testledger.dev', // Defaults to app-api.testledger.dev if none is set
|
|
21
|
+
apiToken : 'tl_abc123_yoursecret', // API token from app.testledger.dev
|
|
23
22
|
projectId : 123, // Only needed if using more than one project
|
|
24
|
-
appVersion :
|
|
23
|
+
appVersion : '2.8.10', // The code version can also be set here
|
|
25
24
|
enableFlaky : 1, // Will mark tests as flaky if it detects them based on previous runs
|
|
26
25
|
uploadArtifacts : true, // Enable screenshot/video artifact uploads
|
|
27
|
-
screenshotDir :
|
|
28
|
-
videoDir :
|
|
26
|
+
screenshotDir : './screenshots', // Directory containing screenshots
|
|
27
|
+
videoDir : './_results_/videos', // Directory containing videos (e.g. from wdio-video-reporter)
|
|
29
28
|
}]],
|
|
30
29
|
```
|
|
31
30
|
|
|
32
|
-
You
|
|
31
|
+
You can create an API token in the UI under Settings -> Profile -> API Keys.
|
|
32
|
+
|
|
33
|
+
**Tip:** Use the `TESTLEDGER_API_TOKEN` environment variable instead of hardcoding the token:
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
services: [['test-ledger', {
|
|
37
|
+
reporterOutputDir : './testledger',
|
|
38
|
+
projectId : 123,
|
|
39
|
+
}]],
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
export TESTLEDGER_API_TOKEN="tl_abc123_yoursecret"
|
|
44
|
+
npx wdio run wdio.conf.js
|
|
45
|
+
```
|
|
33
46
|
|
|
34
47
|
## Add the wdio-test-ledger-reporter to the reporters array in wdio.conf.js
|
|
35
48
|
|
|
@@ -70,8 +83,7 @@ reporters: [
|
|
|
70
83
|
],
|
|
71
84
|
services: [['test-ledger', {
|
|
72
85
|
reporterOutputDir : './testledger',
|
|
73
|
-
|
|
74
|
-
apiToken : 'your-api-token',
|
|
86
|
+
apiToken : 'tl_abc123_yoursecret', // Or use TESTLEDGER_API_TOKEN env var
|
|
75
87
|
uploadArtifacts : true,
|
|
76
88
|
screenshotDir : './screenshots',
|
|
77
89
|
videoDir : './_results_/videos'
|
|
@@ -82,8 +94,9 @@ Artifacts are matched to test suites based on filename. The service looks for th
|
|
|
82
94
|
|
|
83
95
|
## Environment variables
|
|
84
96
|
|
|
85
|
-
Environment variables can be set when running tests
|
|
97
|
+
Environment variables can be set when running tests:
|
|
86
98
|
|
|
99
|
+
* `TESTLEDGER_API_TOKEN` - API token for authentication (recommended for CI)
|
|
87
100
|
* `RUN_TITLE` - Title of the test run. This might be something like a Jira issue key. Defaults to a timestamp if not specified
|
|
88
|
-
* `RUN_UUID` - UUID which can be used to directly link to the test run results. e.g. https://app.testledger.dev/runs
|
|
101
|
+
* `RUN_UUID` - UUID which can be used to directly link to the test run results. e.g. https://app.testledger.dev/runs/<uuid>
|
|
89
102
|
* `APP_VERSION` - Set the version of app this test run ran against
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wdio-test-ledger-service",
|
|
3
|
-
"version": "9.2.
|
|
3
|
+
"version": "9.2.7",
|
|
4
4
|
"description": "WebdriverIO server to send reporter data to testledger.dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/WillBrock/wdio-test-ledger-service#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"btoa": "^1.2.1",
|
|
35
34
|
"fs-extra": "^11.2.0",
|
|
36
35
|
"node-fetch": "^3.3.2"
|
|
37
36
|
},
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import btoa from 'btoa';
|
|
4
3
|
import { SevereServiceError } from 'webdriverio';
|
|
5
4
|
|
|
6
5
|
const api_url = `https://app-api.testledger.dev`;
|
|
@@ -25,9 +24,8 @@ class TestLedgerLauncher {
|
|
|
25
24
|
throw new SevereServiceError(`No reporterOutputDir specified`)
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
// Support env
|
|
27
|
+
// Support env var with fallback to option
|
|
29
28
|
this.apiToken = process.env.TESTLEDGER_API_TOKEN || this.options.apiToken;
|
|
30
|
-
this.username = process.env.TESTLEDGER_USERNAME || this.options.username;
|
|
31
29
|
|
|
32
30
|
if(!this.apiToken) {
|
|
33
31
|
throw new SevereServiceError(`No apiToken specified. Set TESTLEDGER_API_TOKEN env var or pass apiToken option.`)
|
|
@@ -48,7 +46,15 @@ class TestLedgerLauncher {
|
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
async onComplete(exit_code, config) {
|
|
51
|
-
|
|
49
|
+
let data = null;
|
|
50
|
+
try {
|
|
51
|
+
data = this.buildData(config);
|
|
52
|
+
}
|
|
53
|
+
catch(e) {
|
|
54
|
+
fs.writeFileSync(`${this.options.reporterOutputDir}/trio-builddata-error.txt`, e.message, { encoding : `utf-8` });
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
52
58
|
|
|
53
59
|
try {
|
|
54
60
|
const response = await this.post(data);
|
|
@@ -219,11 +225,7 @@ class TestLedgerLauncher {
|
|
|
219
225
|
}
|
|
220
226
|
|
|
221
227
|
getAuthHeader() {
|
|
222
|
-
|
|
223
|
-
if(!this.username) {
|
|
224
|
-
return `Bearer ${this.apiToken}`;
|
|
225
|
-
}
|
|
226
|
-
return `Basic ${btoa(`${this.username}:${this.apiToken}`)}`;
|
|
228
|
+
return `Bearer ${this.apiToken}`;
|
|
227
229
|
}
|
|
228
230
|
|
|
229
231
|
/**
|