@wdio/browser-runner 9.0.0-alpha.78 → 9.0.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/driver.js +249 -234
- package/build/browser/expect.js +107 -148
- package/build/browser/frameworks/mocha.d.ts.map +1 -1
- package/build/browser/integrations/stencil.js +370 -407
- package/build/browser/mock.d.ts +3 -2
- package/build/browser/mock.d.ts.map +1 -1
- package/build/browser/mock.js +78 -34
- package/build/browser/setup.js +313 -37
- package/build/browser/spy.d.ts.map +1 -1
- package/build/browser/spy.js +29 -40
- package/build/browser/utils.d.ts +7 -0
- package/build/browser/utils.d.ts.map +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1465 -171
- package/build/types.d.ts +19 -2
- package/build/types.d.ts.map +1 -1
- package/build/utils.d.ts +3 -3
- package/build/utils.d.ts.map +1 -1
- package/build/vite/constants.d.ts +3 -0
- package/build/vite/constants.d.ts.map +1 -1
- package/build/vite/plugins/esbuild.d.ts.map +1 -1
- package/build/vite/plugins/testrunner.d.ts.map +1 -1
- package/build/vite/server.d.ts +0 -1
- package/build/vite/server.d.ts.map +1 -1
- package/build/vite/utils.d.ts.map +1 -1
- package/package.json +57 -26
- package/build/browser/commands/debug.js +0 -6
- package/build/browser/frameworks/mocha.js +0 -320
- package/build/browser/utils.js +0 -61
- package/build/communicator.js +0 -82
- package/build/constants.js +0 -89
- package/build/types.js +0 -1
- package/build/utils.js +0 -86
- package/build/vite/constants.js +0 -55
- package/build/vite/frameworks/index.js +0 -19
- package/build/vite/frameworks/nuxt.js +0 -61
- package/build/vite/frameworks/stencil.js +0 -165
- package/build/vite/frameworks/tailwindcss.js +0 -28
- package/build/vite/mock.js +0 -50
- package/build/vite/plugins/esbuild.js +0 -25
- package/build/vite/plugins/mockHoisting.js +0 -312
- package/build/vite/plugins/testrunner.js +0 -152
- package/build/vite/plugins/worker.js +0 -12
- package/build/vite/server.js +0 -104
- package/build/vite/types.js +0 -1
- package/build/vite/utils.js +0 -223
- /package/{LICENSE-MIT → LICENSE} +0 -0
package/build/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigEnv, InlineConfig } from 'vite';
|
|
2
|
-
import type { Workers,
|
|
2
|
+
import type { Workers, Options } from '@wdio/types';
|
|
3
3
|
import type { MochaOpts } from '@wdio/mocha-framework';
|
|
4
4
|
import type { IstanbulPluginOptions } from 'vite-plugin-istanbul';
|
|
5
5
|
declare global {
|
|
@@ -102,6 +102,23 @@ export interface BrowserRunnerOptions {
|
|
|
102
102
|
* @default ./__mocks__
|
|
103
103
|
*/
|
|
104
104
|
automockDir?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Set a custom hostname for the server hosting the test files (e.g. the system that runs the WebdriverIO process)
|
|
107
|
+
* in case you are running on a remote grid. Let's say you've set the following capabilities:
|
|
108
|
+
* ```js
|
|
109
|
+
* {
|
|
110
|
+
* hostname: 'company.grid.com',
|
|
111
|
+
* port: 4444,
|
|
112
|
+
* path: '/',
|
|
113
|
+
* protocol: 'http',
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
116
|
+
* In order for the browser to connect to the correct server, you need to set the `hostname` to the IP or hostname
|
|
117
|
+
* of the machine that runs the WebdriverIO process.
|
|
118
|
+
*
|
|
119
|
+
* @default http://0.0.0.0
|
|
120
|
+
*/
|
|
121
|
+
host?: string;
|
|
105
122
|
}
|
|
106
123
|
export interface RunArgs extends Workers.WorkerRunPayload {
|
|
107
124
|
command: string;
|
|
@@ -111,7 +128,7 @@ export interface RunArgs extends Workers.WorkerRunPayload {
|
|
|
111
128
|
export interface Environment {
|
|
112
129
|
args: MochaOpts;
|
|
113
130
|
config: Options.Testrunner;
|
|
114
|
-
capabilities: Capabilities
|
|
131
|
+
capabilities: WebdriverIO.Capabilities;
|
|
115
132
|
sessionId: string;
|
|
116
133
|
injectGlobals: boolean;
|
|
117
134
|
}
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/build/utils.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Options } from '@wdio/types';
|
|
2
2
|
import type { CoverageSummary } from 'istanbul-lib-coverage';
|
|
3
3
|
import { COVERAGE_FACTORS } from './constants.js';
|
|
4
4
|
import type { BrowserRunnerOptions, CoverageOptions } from './types.js';
|
|
5
|
-
export declare function makeHeadless(options: BrowserRunnerOptions, caps: Capabilities
|
|
5
|
+
export declare function makeHeadless(options: BrowserRunnerOptions, caps: WebdriverIO.Capabilities): WebdriverIO.Capabilities;
|
|
6
6
|
/**
|
|
7
7
|
* Open with devtools open when in watch mode
|
|
8
8
|
*/
|
|
9
|
-
export declare function adjustWindowInWatchMode(config: Options.Testrunner, caps: Capabilities
|
|
9
|
+
export declare function adjustWindowInWatchMode(config: Options.Testrunner, caps: WebdriverIO.Capabilities): WebdriverIO.Capabilities;
|
|
10
10
|
export declare function getCoverageByFactor(options: Partial<CoverageOptions>, summary: Pick<CoverageSummary, (typeof COVERAGE_FACTORS)[number]>, fileName?: string): string[];
|
|
11
11
|
//# sourceMappingURL=utils.d.ts.map
|
package/build/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAgB,OAAO,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,OAAO,EAAE,gBAAgB,EAAsD,MAAM,gBAAgB,CAAA;AACrG,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIvE,wBAAgB,YAAY,CAAE,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,WAAW,CAAC,YAAY,GAAG,WAAW,CAAC,YAAY,CA0CrH;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAE,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE,IAAI,EAAE,WAAW,CAAC,YAAY,GAAG,WAAW,CAAC,YAAY,CA0B7H;AAED,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,EACjC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,EACjE,QAAQ,CAAC,EAAE,MAAM,GAcK,MAAM,EAAE,CACjC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { InlineConfig } from 'vite';
|
|
2
2
|
import type { FrameworkPreset } from '../types.js';
|
|
3
|
+
export declare const DEFAULT_PROTOCOL = "http";
|
|
4
|
+
export declare const DEFAULT_HOSTNAME = "localhost";
|
|
5
|
+
export declare const DEFAULT_HOST = "http://localhost";
|
|
3
6
|
export declare const PRESET_DEPENDENCIES: Record<FrameworkPreset, [string, string, any] | undefined>;
|
|
4
7
|
export declare const DEFAULT_VITE_CONFIG: Partial<InlineConfig>;
|
|
5
8
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/vite/constants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAGxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAiB1F,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,YAAY,CAiCrD,CAAA"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/vite/constants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAGxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,eAAO,MAAM,gBAAgB,SAAS,CAAA;AACtC,eAAO,MAAM,gBAAgB,cAAc,CAAA;AAC3C,eAAO,MAAM,YAAY,qBAA8C,CAAA;AACvE,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAiB1F,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,YAAY,CAiCrD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/esbuild.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,SAAS,CAAA;AAElD,wBAAgB,YAAY,
|
|
1
|
+
{"version":3,"file":"esbuild.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/esbuild.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,SAAS,CAAA;AAElD,wBAAgB,YAAY,IAChB,MAAM,CA6BjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testrunner.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/testrunner.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"testrunner.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/testrunner.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AA0ClC,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,oBAAoB,GAAG,MAAM,EAAE,CA+I9E"}
|
package/build/vite/server.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/vite/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/vite/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAO1C,OAAO,KAAK,EAAiB,YAAY,EAAa,MAAM,MAAM,CAAA;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAI1C,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAY3E;;GAEG;AACH,qBAAa,UAAW,SAAQ,YAAY;;IAQxC,IAAI,MAAM,0BAET;gBAEY,OAAO,EAAE,WAAW,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE,aAAa,EAAE,YAAY;IAmC/G,cAAc,CAAE,OAAO,EAAE,kBAAkB;IAIrC,KAAK;IA2CL,KAAK;CAGd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/vite/utils.ts"],"names":[],"mappings":"AAUA,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,CAAC,iBAAU,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/vite/utils.ts"],"names":[],"mappings":"AAUA,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,CAAC,iBAAU,mBA4GvH;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;AAGD,wBAAsB,mBAAmB,CAAE,CAAC,EAAE,MAAM,EAAE,UAAU,WAAY,+BAK3E;AAED,wBAAgB,MAAM,CAAE,CAAC,EAAE,MAAM,oBAEhC;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,UAU9D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/browser-runner",
|
|
3
|
-
"version": "9.0.0
|
|
3
|
+
"version": "9.0.0",
|
|
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",
|
|
@@ -25,28 +25,57 @@
|
|
|
25
25
|
"type": "module",
|
|
26
26
|
"types": "./build/index.d.ts",
|
|
27
27
|
"exports": {
|
|
28
|
-
".":
|
|
29
|
-
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./build/index.d.ts",
|
|
30
|
+
"import": "./build/index.js"
|
|
31
|
+
},
|
|
30
32
|
"./stencil": {
|
|
31
|
-
"
|
|
33
|
+
"importSource": "./src/browser/integrations/stencil.ts",
|
|
34
|
+
"import": "./build/browser/integrations/stencil.js",
|
|
35
|
+
"types": "./build/browser/integrations/stencil.d.ts"
|
|
36
|
+
},
|
|
37
|
+
"./driver": {
|
|
38
|
+
"browserSource": "./src/browser/driver.ts",
|
|
39
|
+
"browser": "./build/browser/driver.js",
|
|
40
|
+
"types": "./build/browser/driver.d.ts"
|
|
41
|
+
},
|
|
42
|
+
"./mock": {
|
|
43
|
+
"browserSource": "./src/browser/mock.ts",
|
|
44
|
+
"browser": "./build/browser/mock.js",
|
|
45
|
+
"types": "./build/browser/mock.d.ts"
|
|
46
|
+
},
|
|
47
|
+
"./setup": {
|
|
48
|
+
"browserSource": "./src/browser/setup.ts",
|
|
49
|
+
"browser": "./build/browser/setup.js",
|
|
50
|
+
"types": "./build/browser/setup.d.ts"
|
|
51
|
+
},
|
|
52
|
+
"./spy": {
|
|
53
|
+
"browserSource": "./src/browser/spy.ts",
|
|
54
|
+
"browser": "./build/browser/spy.js",
|
|
55
|
+
"types": "./build/browser/spy.d.ts"
|
|
56
|
+
},
|
|
57
|
+
"./expect": {
|
|
58
|
+
"browserSource": "./src/browser/expect.ts",
|
|
59
|
+
"browser": "./build/browser/expect.js",
|
|
60
|
+
"types": "./build/browser/expect.d.ts"
|
|
32
61
|
}
|
|
33
62
|
},
|
|
34
63
|
"typeScriptVersion": "3.8.3",
|
|
35
64
|
"dependencies": {
|
|
36
65
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
37
66
|
"@types/istanbul-lib-source-maps": "^4.0.4",
|
|
38
|
-
"@vitest/spy": "^
|
|
39
|
-
"@wdio/globals": "9.0.0
|
|
40
|
-
"@wdio/local-runner": "9.0.0
|
|
41
|
-
"@wdio/logger": "9.0.0
|
|
42
|
-
"@wdio/mocha-framework": "9.0.0
|
|
43
|
-
"@wdio/protocols": "9.0.0
|
|
44
|
-
"@wdio/runner": "9.0.0
|
|
45
|
-
"@wdio/types": "9.0.0
|
|
46
|
-
"@wdio/utils": "9.0.0
|
|
47
|
-
"deepmerge-ts": "^
|
|
67
|
+
"@vitest/spy": "^2.0.4",
|
|
68
|
+
"@wdio/globals": "9.0.0",
|
|
69
|
+
"@wdio/local-runner": "9.0.0",
|
|
70
|
+
"@wdio/logger": "9.0.0",
|
|
71
|
+
"@wdio/mocha-framework": "9.0.0",
|
|
72
|
+
"@wdio/protocols": "9.0.0",
|
|
73
|
+
"@wdio/runner": "9.0.0",
|
|
74
|
+
"@wdio/types": "9.0.0",
|
|
75
|
+
"@wdio/utils": "9.0.0",
|
|
76
|
+
"deepmerge-ts": "^7.0.3",
|
|
48
77
|
"expect": "^29.7.0",
|
|
49
|
-
"expect-webdriverio": "
|
|
78
|
+
"expect-webdriverio": "5.0.0-alpha.2",
|
|
50
79
|
"get-port": "^7.1.0",
|
|
51
80
|
"import-meta-resolve": "^4.0.0",
|
|
52
81
|
"istanbul-lib-coverage": "^3.2.2",
|
|
@@ -58,23 +87,25 @@
|
|
|
58
87
|
"recast": "^0.23.6",
|
|
59
88
|
"safe-stringify": "^1.1.0",
|
|
60
89
|
"source-map-support": "^0.5.21",
|
|
61
|
-
"vite": "~5.
|
|
90
|
+
"vite": "~5.4.0",
|
|
62
91
|
"vite-plugin-istanbul": "^6.0.0",
|
|
63
92
|
"vite-plugin-top-level-await": "^1.4.1",
|
|
64
|
-
"webdriver": "9.0.0
|
|
65
|
-
"webdriverio": "9.0.0
|
|
66
|
-
},
|
|
67
|
-
"scripts": {
|
|
68
|
-
"prepare": "rimraf node_modules/@wdio/config node_modules/@wdio/repl node_modules/@wdio/utils"
|
|
69
|
-
},
|
|
70
|
-
"publishConfig": {
|
|
71
|
-
"access": "public"
|
|
93
|
+
"webdriver": "9.0.0",
|
|
94
|
+
"webdriverio": "9.0.0"
|
|
72
95
|
},
|
|
73
96
|
"devDependencies": {
|
|
74
97
|
"@types/istanbul-lib-coverage": "^2.0.6",
|
|
75
98
|
"@types/istanbul-lib-report": "^3.0.3",
|
|
76
99
|
"@types/istanbul-reports": "^3.0.4",
|
|
77
|
-
"esbuild": "^0.
|
|
100
|
+
"esbuild": "^0.21.3"
|
|
101
|
+
},
|
|
102
|
+
"optionalDependencies": {
|
|
103
|
+
"@nuxt/kit": "^3.12.4",
|
|
104
|
+
"@stencil/core": "^4.20.0",
|
|
105
|
+
"unimport": "^3.10.0"
|
|
106
|
+
},
|
|
107
|
+
"publishConfig": {
|
|
108
|
+
"access": "public"
|
|
78
109
|
},
|
|
79
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "957693463371a4cb329395dcdbce8fb0c930ab93"
|
|
80
111
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export default function debug() {
|
|
2
|
-
return new Promise((resolve) => {
|
|
3
|
-
console.log('%cDebug Mode Enabled', 'background: #ea5906; color: #fff; padding: 3px; border-radius: 5px;', 'enter the command `wdioDebugContinue()` in the console to continue');
|
|
4
|
-
window.wdioDebugContinue = resolve;
|
|
5
|
-
});
|
|
6
|
-
}
|
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import safeStringify from 'safe-stringify';
|
|
2
|
-
import { setupEnv, formatMessage } from '@wdio/mocha-framework/common';
|
|
3
|
-
import { MESSAGE_TYPES } from '@wdio/types';
|
|
4
|
-
import { getCID } from '../utils.js';
|
|
5
|
-
import { EVENTS, WDIO_EVENT_NAME } from '../../constants.js';
|
|
6
|
-
const startTime = Date.now();
|
|
7
|
-
if (!window.Mocha) {
|
|
8
|
-
throw new Error('Can\'t find Mocha attached to the `window` scope, was it installed? Run `npm install mocha` and run again!');
|
|
9
|
-
}
|
|
10
|
-
const BaseReporter = window.Mocha.reporters.html;
|
|
11
|
-
class HTMLReporter extends BaseReporter {
|
|
12
|
-
constructor(runner, options) {
|
|
13
|
-
/**
|
|
14
|
-
* this is a little hack to ensure Mocha attaches the HTML reporter
|
|
15
|
-
* to the element within the Shadow DOM
|
|
16
|
-
*/
|
|
17
|
-
const getElementById = document.getElementById.bind(document);
|
|
18
|
-
document.getElementById = () => document.querySelector('mocha-framework')?.shadowRoot?.querySelector('#mocha');
|
|
19
|
-
super(runner, options);
|
|
20
|
-
document.getElementById = getElementById;
|
|
21
|
-
}
|
|
22
|
-
addCodeToggle() { }
|
|
23
|
-
}
|
|
24
|
-
export class MochaFramework extends HTMLElement {
|
|
25
|
-
#root;
|
|
26
|
-
#spec;
|
|
27
|
-
#require;
|
|
28
|
-
#hookResolver = new Map();
|
|
29
|
-
#runnerEvents = [];
|
|
30
|
-
#isMinified = false;
|
|
31
|
-
constructor() {
|
|
32
|
-
super();
|
|
33
|
-
this.#root = this.attachShadow({ mode: 'open' });
|
|
34
|
-
this.#spec = this.getAttribute('spec');
|
|
35
|
-
this.#require = window.__wdioEnv__.args.require || [];
|
|
36
|
-
delete window.__wdioEnv__.args.require;
|
|
37
|
-
if (!this.#spec) {
|
|
38
|
-
throw new Error('"spec" attribute required but not set');
|
|
39
|
-
}
|
|
40
|
-
mocha.setup({
|
|
41
|
-
...window.__wdioEnv__.args,
|
|
42
|
-
reporter: HTMLReporter
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
static get observedAttributes() {
|
|
46
|
-
return ['minified'];
|
|
47
|
-
}
|
|
48
|
-
get spec() {
|
|
49
|
-
return this.#spec;
|
|
50
|
-
}
|
|
51
|
-
connectedCallback() {
|
|
52
|
-
this.#root.appendChild(template.content.cloneNode(true));
|
|
53
|
-
this.#root.querySelector('.btnCollapseExpand')?.addEventListener('click', () => {
|
|
54
|
-
if (this.#isMinified) {
|
|
55
|
-
this.shadowRoot.host.removeAttribute('minified');
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
this.shadowRoot.host.setAttribute('minified', 'minified');
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
63
|
-
if (name === 'minified') {
|
|
64
|
-
this.#isMinified = typeof newValue === 'string';
|
|
65
|
-
const reporterElem = this.#root.querySelector('.reporter');
|
|
66
|
-
if (reporterElem) {
|
|
67
|
-
reporterElem.className = this.#isMinified ? 'reporter minified' : 'reporter';
|
|
68
|
-
}
|
|
69
|
-
document.body.style.width = `calc(100% - ${this.#isMinified ? '65px' : '500px'})`;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async run() {
|
|
73
|
-
const globalTeardownScripts = [];
|
|
74
|
-
const globalSetupScripts = [];
|
|
75
|
-
for (const r of this.#require) {
|
|
76
|
-
const { mochaGlobalSetup, mochaGlobalTeardown } = (await import(r)) || {};
|
|
77
|
-
if (typeof mochaGlobalSetup === 'function') {
|
|
78
|
-
globalSetupScripts.push(mochaGlobalSetup);
|
|
79
|
-
}
|
|
80
|
-
if (typeof mochaGlobalTeardown === 'function') {
|
|
81
|
-
globalTeardownScripts.push(mochaGlobalTeardown);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const cid = getCID();
|
|
85
|
-
if (!cid) {
|
|
86
|
-
throw new Error('"cid" query parameter is missing');
|
|
87
|
-
}
|
|
88
|
-
const beforeHook = this.#getHook('beforeHook');
|
|
89
|
-
const beforeTest = this.#getHook('beforeTest');
|
|
90
|
-
const afterHook = this.#getHook('afterHook');
|
|
91
|
-
const afterTest = this.#getHook('afterTest');
|
|
92
|
-
setupEnv(cid, window.__wdioEnv__.args, beforeTest, beforeHook, afterTest, afterHook);
|
|
93
|
-
/**
|
|
94
|
-
* import test case (order is important here)
|
|
95
|
-
*/
|
|
96
|
-
const file = this.#spec;
|
|
97
|
-
await import(file);
|
|
98
|
-
/**
|
|
99
|
-
* run setup scripts
|
|
100
|
-
*/
|
|
101
|
-
for (const setupScript of globalSetupScripts) {
|
|
102
|
-
await setupScript();
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* listen on socket events from testrunner
|
|
106
|
-
*/
|
|
107
|
-
import.meta.hot?.on(WDIO_EVENT_NAME, this.#handleSocketMessage.bind(this));
|
|
108
|
-
const self = this;
|
|
109
|
-
const mochaBeforeHook = globalThis.before || globalThis.suiteSetup;
|
|
110
|
-
mochaBeforeHook(async function () {
|
|
111
|
-
const { title, tests, pending, delayed } = this.test?.parent?.suites[0] || {};
|
|
112
|
-
await self.#getHook('beforeSuite')({
|
|
113
|
-
...({ title, tests, pending, delayed }),
|
|
114
|
-
file,
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
const mochaAfterHook = globalThis.after || globalThis.suiteTeardown;
|
|
118
|
-
mochaAfterHook(async function () {
|
|
119
|
-
const { title, tests, pending, delayed } = this.test?.parent?.suites[0] || {};
|
|
120
|
-
await self.#getHook('afterSuite')({
|
|
121
|
-
...({ title, tests, pending, delayed }),
|
|
122
|
-
file,
|
|
123
|
-
duration: Date.now() - startTime
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
/**
|
|
127
|
-
* remove loader animation
|
|
128
|
-
*/
|
|
129
|
-
const spinner = this.#root.querySelector('.lds-ring');
|
|
130
|
-
if (spinner) {
|
|
131
|
-
spinner.remove();
|
|
132
|
-
}
|
|
133
|
-
const runner = mocha.run(async (failures) => {
|
|
134
|
-
await this.#onFinish(failures);
|
|
135
|
-
for (const teardownScript of globalTeardownScripts) {
|
|
136
|
-
await teardownScript();
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
Object.entries(EVENTS).map(([mochaEvent, wdioEvent]) => runner.on(mochaEvent, (payload) => {
|
|
140
|
-
this.#runnerEvents.push(formatMessage({ type: wdioEvent, payload, err: payload.err }));
|
|
141
|
-
}));
|
|
142
|
-
}
|
|
143
|
-
async #onFinish(failures) {
|
|
144
|
-
await this.#getHook('after')(failures, window.__wdioEnv__.capabilities, [this.#spec]);
|
|
145
|
-
/**
|
|
146
|
-
* propagate results to browser so it can be picked up by the runner
|
|
147
|
-
*/
|
|
148
|
-
this.#sendTestReport({ failures, events: this.#runnerEvents });
|
|
149
|
-
console.log(`[WDIO] Finished test suite in ${Date.now() - startTime}ms`);
|
|
150
|
-
}
|
|
151
|
-
#handleSocketMessage(message) {
|
|
152
|
-
if (message.type === MESSAGE_TYPES.hookResultMessage) {
|
|
153
|
-
return this.#handleHookResult(message.value);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
#handleHookResult(result) {
|
|
157
|
-
const resolver = this.#hookResolver.get(result.id);
|
|
158
|
-
if (!resolver) {
|
|
159
|
-
return console.warn(`[WDIO] couldn't find resolve for id "${result.id}"`);
|
|
160
|
-
}
|
|
161
|
-
this.#hookResolver.delete(result.id);
|
|
162
|
-
if (result.error) {
|
|
163
|
-
return resolver.reject(result.error);
|
|
164
|
-
}
|
|
165
|
-
return resolver.resolve();
|
|
166
|
-
}
|
|
167
|
-
#getHook(name) {
|
|
168
|
-
return (...args) => new Promise((resolve, reject) => {
|
|
169
|
-
const id = this.#hookResolver.size + 1;
|
|
170
|
-
const cid = getCID();
|
|
171
|
-
if (!cid) {
|
|
172
|
-
return reject(new Error('"cid" query parameter is missing'));
|
|
173
|
-
}
|
|
174
|
-
this.#hookResolver.set(id, { resolve, reject });
|
|
175
|
-
args = args.map((arg) => {
|
|
176
|
-
if (typeof arg === 'object') {
|
|
177
|
-
const { type, title, body, async, sync, timedOut, pending, parent } = arg;
|
|
178
|
-
return { type, title, body, async, sync, timedOut, pending, parent, file: this.#spec };
|
|
179
|
-
}
|
|
180
|
-
return arg;
|
|
181
|
-
});
|
|
182
|
-
import.meta.hot?.send(WDIO_EVENT_NAME, this.#hookTrigger({ name, id, cid, args }));
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
#hookTrigger(value) {
|
|
186
|
-
return {
|
|
187
|
-
type: MESSAGE_TYPES.hookTriggerMessage,
|
|
188
|
-
value: JSON.parse(safeStringify(value))
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
#sendTestReport(value) {
|
|
192
|
-
import.meta.hot?.send(WDIO_EVENT_NAME, {
|
|
193
|
-
type: MESSAGE_TYPES.browserTestResult,
|
|
194
|
-
value: JSON.parse(safeStringify(value))
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
const template = document.createElement('template');
|
|
199
|
-
template.innerHTML = /*html*/ `
|
|
200
|
-
<style>
|
|
201
|
-
@import "/node_modules/mocha/mocha.css";
|
|
202
|
-
|
|
203
|
-
.reporter {
|
|
204
|
-
transition: width .3s;
|
|
205
|
-
box-shadow: -5px 0px 10px rgb(0 0 0 / 30%);
|
|
206
|
-
position: absolute;
|
|
207
|
-
top: 0;
|
|
208
|
-
right: 0;
|
|
209
|
-
width: 500px;
|
|
210
|
-
height: 100%;
|
|
211
|
-
margin: 0;
|
|
212
|
-
color: var(--mocha-color);
|
|
213
|
-
background-color: var(--mocha-bg-color);
|
|
214
|
-
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iNjRweCIgaGVpZ2h0PSI2NHB4IiB2aWV3Qm94PSIwIDAgNjQgNjQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8dGl0bGU+TG9nbyBSZWd1bGFyPC90aXRsZT4KICAgIDxnIGlkPSJMb2dvLVJlZ3VsYXIiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxyZWN0IGlkPSJSZWN0YW5nbGUiIGZpbGw9IiNFQTU5MDYiIHg9IjAiIHk9IjAiIHdpZHRoPSI2NCIgaGVpZ2h0PSI2NCIgcng9IjUiPjwvcmVjdD4KICAgICAgICA8cGF0aCBkPSJNOCwxNiBMOCw0OCBMNiw0OCBMNiwxNiBMOCwxNiBaIE00MywxNiBDNTEuODM2NTU2LDE2IDU5LDIzLjE2MzQ0NCA1OSwzMiBDNTksNDAuODM2NTU2IDUxLjgzNjU1Niw0OCA0Myw0OCBDMzQuMTYzNDQ0LDQ4IDI3LDQwLjgzNjU1NiAyNywzMiBDMjcsMjMuMTYzNDQ0IDM0LjE2MzQ0NCwxNiA0MywxNiBaIE0yNywxNiBMMTQuMTA2LDQ3Ljk5OTIwNzggTDExLjk5OSw0Ny45OTkyMDc4IEwyNC44OTQsMTYgTDI3LDE2IFogTTQzLDE4IEMzNS4yNjgwMTM1LDE4IDI5LDI0LjI2ODAxMzUgMjksMzIgQzI5LDM5LjczMTk4NjUgMzUuMjY4MDEzNSw0NiA0Myw0NiBDNTAuNzMxOTg2NSw0NiA1NywzOS43MzE5ODY1IDU3LDMyIEM1NywyNC4yNjgwMTM1IDUwLjczMTk4NjUsMTggNDMsMTggWiIgaWQ9IkNvbWJpbmVkLVNoYXBlIiBmaWxsPSIjRkZGRkZGIj48L3BhdGg+CiAgICA8L2c+Cjwvc3ZnPg==);
|
|
215
|
-
background-repeat: no-repeat;
|
|
216
|
-
background-size: 30px;
|
|
217
|
-
background-position: 15px 20px;
|
|
218
|
-
}
|
|
219
|
-
.lds-ring {
|
|
220
|
-
display: inline-block;
|
|
221
|
-
position: absolute;
|
|
222
|
-
top: calc(50% - 40px);
|
|
223
|
-
left: calc(50% - 40px);
|
|
224
|
-
width: 80px;
|
|
225
|
-
height: 80px;
|
|
226
|
-
}
|
|
227
|
-
.lds-ring div {
|
|
228
|
-
box-sizing: border-box;
|
|
229
|
-
display: block;
|
|
230
|
-
position: absolute;
|
|
231
|
-
width: 64px;
|
|
232
|
-
height: 64px;
|
|
233
|
-
margin: 8px;
|
|
234
|
-
border: 4px solid #EA5907;
|
|
235
|
-
border-radius: 50%;
|
|
236
|
-
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
|
|
237
|
-
border-color: #EA5907 transparent transparent transparent;
|
|
238
|
-
}
|
|
239
|
-
.lds-ring div:nth-child(1) {
|
|
240
|
-
animation-delay: -0.45s;
|
|
241
|
-
}
|
|
242
|
-
.lds-ring div:nth-child(2) {
|
|
243
|
-
animation-delay: -0.3s;
|
|
244
|
-
}
|
|
245
|
-
.lds-ring div:nth-child(3) {
|
|
246
|
-
animation-delay: -0.15s;
|
|
247
|
-
}
|
|
248
|
-
@keyframes lds-ring {
|
|
249
|
-
0% {
|
|
250
|
-
transform: rotate(0deg);
|
|
251
|
-
}
|
|
252
|
-
100% {
|
|
253
|
-
transform: rotate(360deg);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
.reporter.minified {
|
|
257
|
-
width: 65px;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
#mocha {
|
|
261
|
-
margin: 0;
|
|
262
|
-
}
|
|
263
|
-
ul#mocha-report {
|
|
264
|
-
transition: opacity .3s;
|
|
265
|
-
opacity: 1;
|
|
266
|
-
padding: 50px 15px 0 0;
|
|
267
|
-
}
|
|
268
|
-
.minified ul#mocha-report {
|
|
269
|
-
opacity: 0;
|
|
270
|
-
}
|
|
271
|
-
.minified .progress {
|
|
272
|
-
display: block;
|
|
273
|
-
float: none;
|
|
274
|
-
}
|
|
275
|
-
.minified #mocha-stats {
|
|
276
|
-
width: 50px;
|
|
277
|
-
padding-top: 60px;
|
|
278
|
-
}
|
|
279
|
-
.minified #mocha-stats li {
|
|
280
|
-
font-size: .9em;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
@keyframes fadeOutIn {
|
|
284
|
-
0% { opacity: 1; }
|
|
285
|
-
20% { opacity: 0; }
|
|
286
|
-
100% { opacity: 1; }
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
.btnCollapseExpand {
|
|
290
|
-
display: block;
|
|
291
|
-
width: 50px;
|
|
292
|
-
position: absolute;
|
|
293
|
-
height: 50px;
|
|
294
|
-
bottom: 0;
|
|
295
|
-
right: 0;
|
|
296
|
-
transition: transform .3s;
|
|
297
|
-
transform: scale(1) translateX(-434px);
|
|
298
|
-
margin: 10px 8px;
|
|
299
|
-
background: transparent;
|
|
300
|
-
border: 0;
|
|
301
|
-
cursor: pointer;
|
|
302
|
-
}
|
|
303
|
-
.minified .btnCollapseExpand {
|
|
304
|
-
transform: scale(-1) translateX(0px);
|
|
305
|
-
animation-name: fadeOutIn;
|
|
306
|
-
animation-duration: .3s;
|
|
307
|
-
}
|
|
308
|
-
</style>
|
|
309
|
-
<div class="reporter">
|
|
310
|
-
<div id="mocha"></div>
|
|
311
|
-
<div class="lds-ring"><div></div><div></div><div></div><div></div></div>
|
|
312
|
-
<button class="btnCollapseExpand">
|
|
313
|
-
<svg width="50" height="40" viewBox="2 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
|
314
|
-
<path fill="#fff" d="M13.11 29.113c7.243 0 13.113-5.871 13.113-13.113S20.353 2.887 13.11 2.887C5.868 2.887-.003 8.758-.003 16S5.868 29.113 13.11 29.113zm0-25.177c6.652 0 12.064 5.412 12.064 12.064S19.762 28.064 13.11 28.064C6.457 28.064 1.046 22.652 1.046 16S6.457 3.936 13.11 3.936z"/>
|
|
315
|
-
<path fill="#fff" d="m13.906 21.637.742.742L21.026 16l-6.378-6.379-.742.742 5.112 5.112H6.291v1.049h12.727z"/>
|
|
316
|
-
</svg>
|
|
317
|
-
</button>
|
|
318
|
-
</div>
|
|
319
|
-
`;
|
|
320
|
-
customElements.define('mocha-framework', MochaFramework);
|
package/build/browser/utils.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export function getCID() {
|
|
2
|
-
const urlParamString = new URLSearchParams(window.location.search);
|
|
3
|
-
const cid = (
|
|
4
|
-
// initial request contains cid as query parameter
|
|
5
|
-
urlParamString.get('cid') ||
|
|
6
|
-
// if not provided check for document cookie, set by `@wdio/runner` package
|
|
7
|
-
(document.cookie.split(';') || [])
|
|
8
|
-
.find((c) => c.includes('WDIO_CID'))
|
|
9
|
-
?.trim()
|
|
10
|
-
.split('=')
|
|
11
|
-
.pop());
|
|
12
|
-
if (!cid) {
|
|
13
|
-
throw new Error('"cid" query parameter is missing');
|
|
14
|
-
}
|
|
15
|
-
return cid;
|
|
16
|
-
}
|
|
17
|
-
export const showPopupWarning = (name, value, defaultValue) => (...params) => {
|
|
18
|
-
const formatedParams = params.map(p => JSON.stringify(p)).join(', ');
|
|
19
|
-
console.warn(`WebdriverIO encountered a \`${name}(${formatedParams})\` call that it cannot handle by default, so it returned \`${value}\`. Read more in https://webdriver.io/docs/runner#limitations.
|
|
20
|
-
If needed, mock the \`${name}\` call manually like:
|
|
21
|
-
\`\`\`
|
|
22
|
-
import { spyOn } from "@wdio/browser-runner"
|
|
23
|
-
spyOn(window, "${name}")${defaultValue ? `.mockReturnValue(${JSON.stringify(defaultValue)})` : ''}
|
|
24
|
-
${name}(${formatedParams})
|
|
25
|
-
expect(${name}).toHaveBeenCalledWith(${formatedParams})
|
|
26
|
-
\`\`\``);
|
|
27
|
-
return value;
|
|
28
|
-
};
|
|
29
|
-
export function sanitizeConsoleArgs(args) {
|
|
30
|
-
return args.map((arg) => {
|
|
31
|
-
if (arg === undefined) {
|
|
32
|
-
return 'undefined';
|
|
33
|
-
}
|
|
34
|
-
try {
|
|
35
|
-
if (arg && typeof arg.selector === 'string' && arg.error) {
|
|
36
|
-
return `WebdriverIO.Element<"${arg.selector}">`;
|
|
37
|
-
}
|
|
38
|
-
if (arg && typeof arg.selector === 'string' && typeof arg.length === 'number') {
|
|
39
|
-
return `WebdriverIO.ElementArray<${arg.length}x "${arg.selector}">`;
|
|
40
|
-
}
|
|
41
|
-
if (arg && typeof arg.selector === 'string') {
|
|
42
|
-
return `WebdriverIO.Element<"${arg.selector}">`;
|
|
43
|
-
}
|
|
44
|
-
if (arg && typeof arg.sessionId === 'string') {
|
|
45
|
-
return `WebdriverIO.Browser<${arg.capabilities.browserName}>`;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
// ignore
|
|
50
|
-
}
|
|
51
|
-
if (arg instanceof HTMLElement ||
|
|
52
|
-
(arg && typeof arg === 'object' && typeof arg.then === 'function') ||
|
|
53
|
-
typeof arg === 'function') {
|
|
54
|
-
return arg.toString();
|
|
55
|
-
}
|
|
56
|
-
if (arg instanceof Error) {
|
|
57
|
-
return arg.stack;
|
|
58
|
-
}
|
|
59
|
-
return arg;
|
|
60
|
-
});
|
|
61
|
-
}
|