@wdio/globals 8.0.0-alpha.593 → 8.0.0-alpha.600
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/cjs/index.js +63 -0
- package/cjs/package.json +3 -0
- package/package.json +12 -5
- package/tsconfig.cjs.json +9 -0
package/cjs/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
const globals = new Map();
|
|
6
|
+
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.';
|
|
7
|
+
function proxyHandler(key) {
|
|
8
|
+
return {
|
|
9
|
+
get: (self, prop) => {
|
|
10
|
+
if (!globals.has(key)) {
|
|
11
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
12
|
+
}
|
|
13
|
+
return globals.get(key)[prop];
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.browser = new Proxy(class Browser {
|
|
18
|
+
}, proxyHandler('browser'));
|
|
19
|
+
exports.driver = new Proxy(class Browser {
|
|
20
|
+
}, proxyHandler('driver'));
|
|
21
|
+
exports.multiremotebrowser = new Proxy(class Browser {
|
|
22
|
+
}, proxyHandler('multiremotebrowser'));
|
|
23
|
+
const $ = (...args) => {
|
|
24
|
+
if (!globals.has('$')) {
|
|
25
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
26
|
+
}
|
|
27
|
+
return globals.get('$')(...args);
|
|
28
|
+
};
|
|
29
|
+
exports.$ = $;
|
|
30
|
+
const $$ = (...args) => {
|
|
31
|
+
if (!globals.has('$$')) {
|
|
32
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
33
|
+
}
|
|
34
|
+
return globals.get('$$')(...args);
|
|
35
|
+
};
|
|
36
|
+
exports.$$ = $$;
|
|
37
|
+
exports.expect = ((...args) => {
|
|
38
|
+
if (!globals.has('expect')) {
|
|
39
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
40
|
+
}
|
|
41
|
+
return globals.get('expect')(...args);
|
|
42
|
+
});
|
|
43
|
+
exports.expect.extend = (...args) => {
|
|
44
|
+
if (!globals.has('expect')) {
|
|
45
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
46
|
+
}
|
|
47
|
+
const expect = globals.get('expect');
|
|
48
|
+
return expect.extend(...args);
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* allows to set global property to be imported and used later on
|
|
52
|
+
* @param key global key
|
|
53
|
+
* @param value actual value to be returned
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
function _setGlobal(key, value, setGlobal = true) {
|
|
57
|
+
globals.set(key, value);
|
|
58
|
+
if (setGlobal) {
|
|
59
|
+
// @ts-expect-error
|
|
60
|
+
globalThis[key] = value;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
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.600+dffc6ae4e",
|
|
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.600+dffc6ae4e"
|
|
37
44
|
},
|
|
38
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "dffc6ae4ed2160de6972e99b563c45819ea98ecb"
|
|
39
46
|
}
|