@wdio/globals 8.0.0-alpha.598 → 8.0.0-alpha.607
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/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +8 -1
- package/cjs/index.js +70 -0
- package/cjs/package.json +3 -0
- package/package.json +12 -5
package/build/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/// <reference types="./standalone" />
|
|
2
2
|
/// <reference types="types" />
|
|
3
3
|
type SupportedGlobals = 'browser' | 'driver' | 'multiremotebrowser' | '$' | '$$' | 'expect';
|
|
4
|
+
declare global {
|
|
5
|
+
var _wdioGlobals: Map<SupportedGlobals, any>;
|
|
6
|
+
}
|
|
4
7
|
export declare const browser: WebdriverIO.Browser;
|
|
5
8
|
export declare const driver: WebdriverIO.Browser;
|
|
6
9
|
export declare const multiremotebrowser: WebdriverIO.MultiRemoteBrowser;
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAEA,KAAK,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,oBAAoB,GAAG,GAAG,GAAG,IAAI,GAAG,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAEA,KAAK,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,oBAAoB,GAAG,GAAG,GAAG,IAAI,GAAG,QAAQ,CAAA;AAE3F,OAAO,CAAC,MAAM,CAAC;IACX,IAAI,YAAY,EAAE,GAAG,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAA;CAC/C;AAwBD,eAAO,MAAM,OAAO,EAAE,WAAW,CAAC,OAGjC,CAAA;AACD,eAAO,MAAM,MAAM,EAAE,WAAW,CAAC,OAGhC,CAAA;AACD,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,kBAG5C,CAAA;AACD,eAAO,MAAM,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,CAKtC,CAAA;AACD,eAAO,MAAM,EAAE,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAKxC,CAAA;AACD,eAAO,MAAM,MAAM,EAAE,iBAAiB,CAAC,MAKT,CAAA;AAU9B;;;;;GAKG;AACH,wBAAgB,UAAU,CAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,UAAO,QAO9E"}
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
/// <reference path="../types.d.ts" />
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* As this file gets imported/used as ESM and CJS artifact we have to make sure
|
|
4
|
+
* that we can share the globals map across both files. For example if someone
|
|
5
|
+
* runs a CJS project, we run this file as ESM (/build/index.js) first, but when
|
|
6
|
+
* imported in the test, the same file will be used as CJS version (/cjs/index.js)
|
|
7
|
+
* and can use the Map initiated by the testrunner by making it accessible globally.
|
|
8
|
+
*/
|
|
9
|
+
const globals = globalThis._wdioGlobals = globalThis._wdioGlobals || new Map();
|
|
3
10
|
const GLOBALS_ERROR_MESSAGE = 'No browser instance registered. Don\'t import @wdio/globals outside of the WDIO testrunner context. Or you have two two different "@wdio/globals" packages installed.';
|
|
4
11
|
function proxyHandler(key) {
|
|
5
12
|
return {
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/// <reference path="../types.d.ts" />
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports._setGlobal = exports.expect = exports.$$ = exports.$ = exports.multiremotebrowser = exports.driver = exports.browser = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* As this file gets imported/used as ESM and CJS artifact we have to make sure
|
|
7
|
+
* that we can share the globals map across both files. For example if someone
|
|
8
|
+
* runs a CJS project, we run this file as ESM (/build/index.js) first, but when
|
|
9
|
+
* imported in the test, the same file will be used as CJS version (/cjs/index.js)
|
|
10
|
+
* and can use the Map initiated by the testrunner by making it accessible globally.
|
|
11
|
+
*/
|
|
12
|
+
const globals = globalThis._wdioGlobals = globalThis._wdioGlobals || new Map();
|
|
13
|
+
const GLOBALS_ERROR_MESSAGE = 'No browser instance registered. Don\'t import @wdio/globals outside of the WDIO testrunner context. Or you have two two different "@wdio/globals" packages installed.';
|
|
14
|
+
function proxyHandler(key) {
|
|
15
|
+
return {
|
|
16
|
+
get: (self, prop) => {
|
|
17
|
+
if (!globals.has(key)) {
|
|
18
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
19
|
+
}
|
|
20
|
+
return globals.get(key)[prop];
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.browser = new Proxy(class Browser {
|
|
25
|
+
}, proxyHandler('browser'));
|
|
26
|
+
exports.driver = new Proxy(class Browser {
|
|
27
|
+
}, proxyHandler('driver'));
|
|
28
|
+
exports.multiremotebrowser = new Proxy(class Browser {
|
|
29
|
+
}, proxyHandler('multiremotebrowser'));
|
|
30
|
+
const $ = (...args) => {
|
|
31
|
+
if (!globals.has('$')) {
|
|
32
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
33
|
+
}
|
|
34
|
+
return globals.get('$')(...args);
|
|
35
|
+
};
|
|
36
|
+
exports.$ = $;
|
|
37
|
+
const $$ = (...args) => {
|
|
38
|
+
if (!globals.has('$$')) {
|
|
39
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
40
|
+
}
|
|
41
|
+
return globals.get('$$')(...args);
|
|
42
|
+
};
|
|
43
|
+
exports.$$ = $$;
|
|
44
|
+
exports.expect = ((...args) => {
|
|
45
|
+
if (!globals.has('expect')) {
|
|
46
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
47
|
+
}
|
|
48
|
+
return globals.get('expect')(...args);
|
|
49
|
+
});
|
|
50
|
+
exports.expect.extend = (...args) => {
|
|
51
|
+
if (!globals.has('expect')) {
|
|
52
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
53
|
+
}
|
|
54
|
+
const expect = globals.get('expect');
|
|
55
|
+
return expect.extend(...args);
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* allows to set global property to be imported and used later on
|
|
59
|
+
* @param key global key
|
|
60
|
+
* @param value actual value to be returned
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
function _setGlobal(key, value, setGlobal = true) {
|
|
64
|
+
globals.set(key, value);
|
|
65
|
+
if (setGlobal) {
|
|
66
|
+
// @ts-expect-error
|
|
67
|
+
globalThis[key] = value;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports._setGlobal = _setGlobal;
|
package/cjs/package.json
ADDED
package/package.json
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/globals",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.607+dac623702",
|
|
4
4
|
"description": "A helper utility for importing global variables directly",
|
|
5
5
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-globals",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"main": "./cjs/index.js",
|
|
8
9
|
"type": "module",
|
|
10
|
+
"module": "./build/index.js",
|
|
9
11
|
"exports": {
|
|
10
|
-
".":
|
|
11
|
-
|
|
12
|
+
".": [
|
|
13
|
+
{
|
|
14
|
+
"import": "./build/index.js",
|
|
15
|
+
"require": "./cjs/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./cjs/index.js"
|
|
18
|
+
]
|
|
12
19
|
},
|
|
13
20
|
"types": "./build/index.d.ts",
|
|
14
21
|
"typeScriptVersion": "3.8.3",
|
|
@@ -33,7 +40,7 @@
|
|
|
33
40
|
},
|
|
34
41
|
"optionalDependencies": {
|
|
35
42
|
"expect-webdriverio": "^4.0.0-alpha.6",
|
|
36
|
-
"webdriverio": "8.0.0-alpha.
|
|
43
|
+
"webdriverio": "8.0.0-alpha.607+dac623702"
|
|
37
44
|
},
|
|
38
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "dac62370266d145eeeafbfbea7e470d65a7ab663"
|
|
39
46
|
}
|