@wdio/browser-runner 8.8.2 → 8.8.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocha.d.ts","sourceRoot":"","sources":["../../../src/browser/frameworks/mocha.ts"],"names":[],"mappings":"AA8BA,qBAAa,cAAe,SAAQ,WAAW;;;
|
|
1
|
+
{"version":3,"file":"mocha.d.ts","sourceRoot":"","sources":["../../../src/browser/frameworks/mocha.ts"],"names":[],"mappings":"AA8BA,qBAAa,cAAe,SAAQ,WAAW;;;IA0B3C,MAAM,KAAK,kBAAkB,aAE5B;IAED,iBAAiB;IAWjB,wBAAwB,CAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO;IAatE,GAAG,CAAE,MAAM,EAAE,SAAS;CA4H/B"}
|
|
@@ -24,6 +24,7 @@ export class MochaFramework extends HTMLElement {
|
|
|
24
24
|
#root;
|
|
25
25
|
#spec;
|
|
26
26
|
#socket;
|
|
27
|
+
#require;
|
|
27
28
|
#hookResolver = new Map();
|
|
28
29
|
#runnerEvents = [];
|
|
29
30
|
#isMinified = false;
|
|
@@ -31,6 +32,8 @@ export class MochaFramework extends HTMLElement {
|
|
|
31
32
|
super();
|
|
32
33
|
this.#root = this.attachShadow({ mode: 'open' });
|
|
33
34
|
this.#spec = this.getAttribute('spec');
|
|
35
|
+
this.#require = window.__wdioEnv__.args.require || [];
|
|
36
|
+
delete window.__wdioEnv__.args.require;
|
|
34
37
|
if (!this.#spec) {
|
|
35
38
|
throw new Error('"spec" attribute required but not set');
|
|
36
39
|
}
|
|
@@ -64,11 +67,28 @@ export class MochaFramework extends HTMLElement {
|
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
async run(socket) {
|
|
70
|
+
const globalTeardownScripts = [];
|
|
71
|
+
const globalSetupScripts = [];
|
|
72
|
+
for (const r of this.#require) {
|
|
73
|
+
const { mochaGlobalSetup, mochaGlobalTeardown } = (await import(r)) || {};
|
|
74
|
+
if (typeof mochaGlobalSetup === 'function') {
|
|
75
|
+
globalSetupScripts.push(mochaGlobalSetup);
|
|
76
|
+
}
|
|
77
|
+
if (typeof mochaGlobalTeardown === 'function') {
|
|
78
|
+
globalTeardownScripts.push(mochaGlobalTeardown);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
67
81
|
/**
|
|
68
82
|
* import test case (order is important here)
|
|
69
83
|
*/
|
|
70
84
|
const file = this.#spec;
|
|
71
85
|
await import(file);
|
|
86
|
+
/**
|
|
87
|
+
* run setup scripts
|
|
88
|
+
*/
|
|
89
|
+
for (const setupScript of globalSetupScripts) {
|
|
90
|
+
await setupScript();
|
|
91
|
+
}
|
|
72
92
|
this.#socket = socket;
|
|
73
93
|
socket.addEventListener('message', this.#handleSocketMessage.bind(this));
|
|
74
94
|
const cid = getCID();
|
|
@@ -81,20 +101,27 @@ export class MochaFramework extends HTMLElement {
|
|
|
81
101
|
const afterTest = this.#getHook('afterTest');
|
|
82
102
|
setupEnv(cid, window.__wdioEnv__.args, beforeTest, beforeHook, afterTest, afterHook);
|
|
83
103
|
const self = this;
|
|
84
|
-
before
|
|
104
|
+
const mochaBeforeHook = globalThis.before || globalThis.suiteSetup;
|
|
105
|
+
mochaBeforeHook(function () {
|
|
85
106
|
self.#getHook('beforeSuite')({
|
|
86
107
|
...this.test?.parent?.suites[0],
|
|
87
108
|
file,
|
|
88
109
|
});
|
|
89
110
|
});
|
|
90
|
-
after
|
|
111
|
+
const mochaAfterHook = globalThis.after || globalThis.suiteTeardown;
|
|
112
|
+
mochaAfterHook(function () {
|
|
91
113
|
self.#getHook('afterSuite')({
|
|
92
114
|
...this.test?.parent?.suites[0],
|
|
93
115
|
file,
|
|
94
116
|
duration: Date.now() - startTime
|
|
95
117
|
});
|
|
96
118
|
});
|
|
97
|
-
const runner = mocha.run(
|
|
119
|
+
const runner = mocha.run(async (failures) => {
|
|
120
|
+
await this.#onFinish(failures);
|
|
121
|
+
for (const teardownScript of globalTeardownScripts) {
|
|
122
|
+
await teardownScript();
|
|
123
|
+
}
|
|
124
|
+
});
|
|
98
125
|
Object.entries(EVENTS).map(([mochaEvent, wdioEvent]) => runner.on(mochaEvent, (payload) => {
|
|
99
126
|
this.#runnerEvents.push(formatMessage({ type: wdioEvent, payload, err: payload.err }));
|
|
100
127
|
}));
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAO5C,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAS/G,OAAO,KAAK,EAAE,oBAAoB,IAAI,0BAA0B,EAAmB,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAG5H,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;;IAU9C,OAAO,CAAC,OAAO;IACf,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU;IAJzC,OAAO,CAAC,aAAa,CAAoB;gBAG7B,OAAO,EAAE,0BAA0B,EACjC,OAAO,EAAE,OAAO,CAAC,UAAU;IAuBzC;;OAEG;IACG,UAAU;IAoBhB,GAAG,CAAE,OAAO,EAAE,OAAO,GAAG,cAAc;IAwBtC;;;;OAIG;IACG,QAAQ;YA8CA,wBAAwB;CA2DzC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,WAAW,CAAC;QAClB,UAAU,oBAAqB,SAAQ,0BAA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,CAAC,CAAC,CAAC,CAAA"}
|
package/build/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
|
+
import url from 'node:url';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import logger from '@wdio/logger';
|
|
4
5
|
import LocalRunner from '@wdio/local-runner';
|
|
@@ -31,6 +32,14 @@ export default class BrowserRunner extends LocalRunner {
|
|
|
31
32
|
this.#config = _config;
|
|
32
33
|
this.#coverageOptions = options.coverage || {};
|
|
33
34
|
this.#reportsDirectory = this.#coverageOptions.reportsDirectory || path.join(this.#config.rootDir, DEFAULT_REPORTS_DIRECTORY);
|
|
35
|
+
/**
|
|
36
|
+
* transform mochaOpts require params so we can use it in the browser
|
|
37
|
+
*/
|
|
38
|
+
if (this.#config.mochaOpts) {
|
|
39
|
+
this.#config.mochaOpts.require = (this.#config.mochaOpts.require || [])
|
|
40
|
+
.map((r) => path.join(this.#config.rootDir || process.cwd(), r))
|
|
41
|
+
.map((r) => url.pathToFileURL(r).pathname);
|
|
42
|
+
}
|
|
34
43
|
}
|
|
35
44
|
/**
|
|
36
45
|
* nothing to initialise when running locally
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/vite/utils.ts"],"names":[],"mappings":";AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAI/D,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,oBAAc,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/vite/utils.ts"],"names":[],"mappings":";AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAI/D,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,oBAAc,mBA8FpI;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,MAAM,gBAa7E;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAY7D;AAED,wBAAsB,qBAAqB,CAAE,GAAG,EAAE,MAAM,qBAqBvD;AAGD,wBAAsB,cAAc,CAAC,WAAW,EAAE,MAAM,+BAgBvD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,UAU9D"}
|
package/build/vite/utils.js
CHANGED
|
@@ -8,6 +8,7 @@ const log = logger('@wdio/browser-runner');
|
|
|
8
8
|
export async function getTemplate(options, env, spec, processEnv = process.env) {
|
|
9
9
|
const root = options.rootDir || process.cwd();
|
|
10
10
|
const rootFileUrl = url.pathToFileURL(root).href;
|
|
11
|
+
const isHeadless = options.headless || Boolean(process.env.CI);
|
|
11
12
|
let vueDeps = '';
|
|
12
13
|
if (options.preset === 'vue') {
|
|
13
14
|
try {
|
|
@@ -88,7 +89,7 @@ export async function getTemplate(options, env, spec, processEnv = process.env)
|
|
|
88
89
|
${vueDeps}
|
|
89
90
|
</head>
|
|
90
91
|
<body>
|
|
91
|
-
<mocha-framework spec="${spec}" ${
|
|
92
|
+
<mocha-framework spec="${spec}" ${isHeadless ? 'style="display: none"' : ''}></mocha-framework>
|
|
92
93
|
<script type="module">
|
|
93
94
|
window.process.env = ${JSON.stringify(processEnv)}
|
|
94
95
|
</script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/browser-runner",
|
|
3
|
-
"version": "8.8.
|
|
3
|
+
"version": "8.8.5",
|
|
4
4
|
"description": "A WebdriverIO runner to run unit tests tests in the browser.",
|
|
5
5
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-browser-runner",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"@types/istanbul-lib-source-maps": "^4.0.1",
|
|
36
36
|
"@types/node": "^18.15.3",
|
|
37
37
|
"@vitest/spy": "^0.30.0",
|
|
38
|
-
"@wdio/globals": "8.8.
|
|
39
|
-
"@wdio/local-runner": "8.8.
|
|
38
|
+
"@wdio/globals": "8.8.4",
|
|
39
|
+
"@wdio/local-runner": "8.8.4",
|
|
40
40
|
"@wdio/logger": "8.6.6",
|
|
41
|
-
"@wdio/mocha-framework": "8.8.
|
|
41
|
+
"@wdio/mocha-framework": "8.8.4",
|
|
42
42
|
"@wdio/protocols": "8.8.1",
|
|
43
|
-
"@wdio/types": "8.8.
|
|
44
|
-
"@wdio/utils": "8.8.
|
|
43
|
+
"@wdio/types": "8.8.4",
|
|
44
|
+
"@wdio/utils": "8.8.4",
|
|
45
45
|
"ast-types": "^0.14.2",
|
|
46
46
|
"deepmerge-ts": "^5.0.0",
|
|
47
47
|
"expect-webdriverio": "^4.1.2",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"vite": "^4.2.0",
|
|
60
60
|
"vite-plugin-istanbul": "^4.0.1",
|
|
61
61
|
"vite-plugin-top-level-await": "^1.3.0",
|
|
62
|
-
"webdriver": "8.8.
|
|
63
|
-
"webdriverio": "8.8.
|
|
62
|
+
"webdriver": "8.8.4",
|
|
63
|
+
"webdriverio": "8.8.4",
|
|
64
64
|
"ws": "^8.13.0"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/ws": "^8.5.4",
|
|
74
|
-
"@wdio/runner": "8.8.
|
|
74
|
+
"@wdio/runner": "8.8.4"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "ec5d93e7227c93933463642f19d6feb34cc74991"
|
|
77
77
|
}
|