@wdio/runner 8.2.4 → 8.3.0
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/build/browser.d.ts +1 -0
- package/build/browser.d.ts.map +1 -1
- package/build/browser.js +26 -3
- package/package.json +8 -8
package/build/browser.d.ts
CHANGED
package/build/browser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAW,OAAO,EAAY,MAAM,aAAa,CAAA;AAE3E,OAAO,KAAK,YAAY,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAA6C,MAAM,YAAY,CAAA;AAM1F,KAAK,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC,GAAG;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAOpG,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,cAAc,EAAE,cAAc,EAAE,CAAA;QAChC,cAAc,EAAE,GAAG,EAAE,CAAA;QACrB,gBAAgB,EAAE,MAAM,CAAA;QACxB,YAAY,CAAC,EAAE,OAAO,CAAA;KACzB;CACJ;AAID,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;;IAKpE,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS;gBAJT,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,CAAC,UAAU,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,EACpD,MAAM,EAAE,MAAM,EAAE,EAChB,aAAa,EAAE,YAAY,CAAC,gBAAgB,EAC5C,SAAS,EAAE,YAAY;IASnC;;OAEG;IACH,QAAQ;IAIR,IAAI;IAIE,GAAG;IAoKT,MAAM,CAAC,IAAI,CAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,YAAY,CAAC,gBAAgB,EAAE,QAAQ,EAAE,YAAY;CAItH"}
|
package/build/browser.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import url from 'node:url';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
3
4
|
import logger from '@wdio/logger';
|
|
4
5
|
import { browser } from '@wdio/globals';
|
|
5
6
|
import { executeHooksWithArgs } from '@wdio/utils';
|
|
7
|
+
const DEFAULT_REPORTS_DIRECTORY = 'coverage';
|
|
6
8
|
const log = logger('@wdio/runner');
|
|
7
9
|
const sep = '\n - ';
|
|
8
10
|
const sleep = (ms = 100) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
9
|
-
const TEST_TIMEOUT = 15 * 1000;
|
|
10
11
|
export default class BrowserFramework {
|
|
11
12
|
_cid;
|
|
12
13
|
_config;
|
|
@@ -14,6 +15,7 @@ export default class BrowserFramework {
|
|
|
14
15
|
_capabilities;
|
|
15
16
|
_reporter;
|
|
16
17
|
#inDebugMode = false;
|
|
18
|
+
#runnerOptions; // `any` here because we don't want to create a dependency to @wdio/browser-runner
|
|
17
19
|
constructor(_cid, _config, _specs, _capabilities, _reporter) {
|
|
18
20
|
this._cid = _cid;
|
|
19
21
|
this._config = _config;
|
|
@@ -22,6 +24,8 @@ export default class BrowserFramework {
|
|
|
22
24
|
this._reporter = _reporter;
|
|
23
25
|
// listen on testrunner events
|
|
24
26
|
process.on('message', this.#handleProcessMessage.bind(this));
|
|
27
|
+
const [, runnerOptions] = Array.isArray(_config.runner) ? _config.runner : [];
|
|
28
|
+
this.#runnerOptions = runnerOptions || {};
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
31
|
* always return true as it is unrelevant for component testing
|
|
@@ -51,11 +55,13 @@ export default class BrowserFramework {
|
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
async #loop() {
|
|
58
|
+
const timeout = this._config.mochaOpts.timeout;
|
|
54
59
|
/**
|
|
55
60
|
* start tests
|
|
56
61
|
*/
|
|
57
62
|
let failures = 0;
|
|
58
63
|
let uid = 0;
|
|
64
|
+
let coverage = {};
|
|
59
65
|
for (const spec of this._specs) {
|
|
60
66
|
log.info(`Run spec file ${spec} for cid ${this._cid}`);
|
|
61
67
|
/**
|
|
@@ -74,7 +80,7 @@ export default class BrowserFramework {
|
|
|
74
80
|
const now = Date.now();
|
|
75
81
|
await browser.waitUntil(async () => {
|
|
76
82
|
while (typeof state.failures !== 'number' && (!state.errors || state.errors.length === 0)) {
|
|
77
|
-
if ((Date.now() - now) >
|
|
83
|
+
if ((Date.now() - now) > timeout) {
|
|
78
84
|
return false;
|
|
79
85
|
}
|
|
80
86
|
await sleep();
|
|
@@ -106,8 +112,15 @@ export default class BrowserFramework {
|
|
|
106
112
|
return true;
|
|
107
113
|
}, {
|
|
108
114
|
timeoutMsg: 'browser test timed out',
|
|
109
|
-
timeout
|
|
115
|
+
timeout
|
|
110
116
|
});
|
|
117
|
+
/**
|
|
118
|
+
* capture coverage if enabled
|
|
119
|
+
*/
|
|
120
|
+
if (this.#runnerOptions.coverage?.enabled) {
|
|
121
|
+
const coverageJson = await browser.execute(() => window.__coverage__ || {});
|
|
122
|
+
coverage = { ...coverage, ...coverageJson };
|
|
123
|
+
}
|
|
111
124
|
if (state.errors?.length) {
|
|
112
125
|
const errors = state.errors.map((ev) => state.hasViteError
|
|
113
126
|
? ev.message
|
|
@@ -126,6 +139,16 @@ export default class BrowserFramework {
|
|
|
126
139
|
await this.#fetchEvents(browser, spec, ++uid);
|
|
127
140
|
failures += state.failures || 0;
|
|
128
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* write coverage results
|
|
144
|
+
*/
|
|
145
|
+
const filesWithCoverageReports = Object.keys(coverage).length;
|
|
146
|
+
if (filesWithCoverageReports > 0) {
|
|
147
|
+
log.info(`Found ${filesWithCoverageReports} file with a test coverage report`);
|
|
148
|
+
const reportsDirectory = this.#runnerOptions.coverage?.reportsDirectory || path.join(this._config.rootDir, DEFAULT_REPORTS_DIRECTORY);
|
|
149
|
+
await fs.mkdir(reportsDirectory, { recursive: true });
|
|
150
|
+
await fs.writeFile(path.join(reportsDirectory, 'out.json'), JSON.stringify(coverage, null, 2));
|
|
151
|
+
}
|
|
129
152
|
return failures;
|
|
130
153
|
}
|
|
131
154
|
async #fetchEvents(browser, spec, uid) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/runner",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"description": "A WebdriverIO service that runs tests in arbitrary environments",
|
|
5
5
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-runner",
|
|
@@ -27,19 +27,19 @@
|
|
|
27
27
|
"typeScriptVersion": "3.8.3",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@types/node": "^18.0.0",
|
|
30
|
-
"@wdio/config": "8.
|
|
31
|
-
"@wdio/globals": "8.
|
|
30
|
+
"@wdio/config": "8.3.0",
|
|
31
|
+
"@wdio/globals": "8.3.0",
|
|
32
32
|
"@wdio/logger": "8.1.0",
|
|
33
|
-
"@wdio/types": "8.
|
|
34
|
-
"@wdio/utils": "8.
|
|
33
|
+
"@wdio/types": "8.3.0",
|
|
34
|
+
"@wdio/utils": "8.3.0",
|
|
35
35
|
"deepmerge-ts": "^4.2.2",
|
|
36
36
|
"expect-webdriverio": "^4.0.1",
|
|
37
37
|
"gaze": "^1.1.2",
|
|
38
|
-
"webdriver": "8.
|
|
39
|
-
"webdriverio": "8.
|
|
38
|
+
"webdriver": "8.3.0",
|
|
39
|
+
"webdriverio": "8.3.0"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "156a246e8117463cf3c762d2da5bf9eef3a476ea"
|
|
45
45
|
}
|