@wdio/globals 9.0.0-alpha.9 → 9.0.1
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.cjs +127 -0
- package/build/index.d.ts +8 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +82 -80
- package/package.json +13 -15
- package/types.d.ts +2 -1
- package/cjs/index.js +0 -99
- package/cjs/package.json +0 -5
- /package/{LICENSE-MIT → LICENSE} +0 -0
package/build/index.cjs
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
const __importMetaUrl = require('url').pathToFileURL(__filename).href;
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var src_exports = {};
|
|
23
|
+
__export(src_exports, {
|
|
24
|
+
$: () => $,
|
|
25
|
+
$$: () => $$,
|
|
26
|
+
_setGlobal: () => _setGlobal,
|
|
27
|
+
browser: () => browser,
|
|
28
|
+
driver: () => driver,
|
|
29
|
+
expect: () => expect,
|
|
30
|
+
multiremotebrowser: () => multiremotebrowser
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
|
33
|
+
var globals = globalThis._wdioGlobals = globalThis._wdioGlobals || /* @__PURE__ */ new Map();
|
|
34
|
+
var 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.`;
|
|
35
|
+
function proxyHandler(key) {
|
|
36
|
+
return {
|
|
37
|
+
get: (self, prop) => {
|
|
38
|
+
if (!globals.has(key)) {
|
|
39
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
40
|
+
}
|
|
41
|
+
const receiver = globals.get(key);
|
|
42
|
+
const field = receiver[prop];
|
|
43
|
+
return typeof field === "function" ? field.bind(receiver) : field;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
var browser = new Proxy(
|
|
48
|
+
class Browser {
|
|
49
|
+
},
|
|
50
|
+
proxyHandler("browser")
|
|
51
|
+
);
|
|
52
|
+
var driver = new Proxy(
|
|
53
|
+
class Browser2 {
|
|
54
|
+
},
|
|
55
|
+
proxyHandler("driver")
|
|
56
|
+
);
|
|
57
|
+
var multiremotebrowser = new Proxy(
|
|
58
|
+
class Browser3 {
|
|
59
|
+
},
|
|
60
|
+
proxyHandler("multiremotebrowser")
|
|
61
|
+
);
|
|
62
|
+
var $ = (...args) => {
|
|
63
|
+
if (!globals.has("$")) {
|
|
64
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
65
|
+
}
|
|
66
|
+
return globals.get("$")(...args);
|
|
67
|
+
};
|
|
68
|
+
var $$ = (...args) => {
|
|
69
|
+
if (!globals.has("$$")) {
|
|
70
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
71
|
+
}
|
|
72
|
+
return globals.get("$$")(...args);
|
|
73
|
+
};
|
|
74
|
+
var expect = (...args) => {
|
|
75
|
+
if (!globals.has("expect")) {
|
|
76
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
77
|
+
}
|
|
78
|
+
return globals.get("expect")(...args);
|
|
79
|
+
};
|
|
80
|
+
var ASYNC_MATCHERS = [
|
|
81
|
+
"any",
|
|
82
|
+
"anything",
|
|
83
|
+
"arrayContaining",
|
|
84
|
+
"objectContaining",
|
|
85
|
+
"stringContaining",
|
|
86
|
+
"stringMatching"
|
|
87
|
+
];
|
|
88
|
+
for (const matcher of ASYNC_MATCHERS) {
|
|
89
|
+
expect[matcher] = (...args) => {
|
|
90
|
+
if (!globals.has("expect")) {
|
|
91
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
92
|
+
}
|
|
93
|
+
return globals.get("expect")[matcher](...args);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
expect.not = ASYNC_MATCHERS.reduce((acc, matcher) => {
|
|
97
|
+
acc[matcher] = (...args) => {
|
|
98
|
+
if (!globals.has("expect")) {
|
|
99
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
100
|
+
}
|
|
101
|
+
return globals.get("expect").not[matcher](...args);
|
|
102
|
+
};
|
|
103
|
+
return acc;
|
|
104
|
+
}, {});
|
|
105
|
+
expect.extend = (...args) => {
|
|
106
|
+
if (!globals.has("expect")) {
|
|
107
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
108
|
+
}
|
|
109
|
+
const expect2 = globals.get("expect");
|
|
110
|
+
return expect2.extend(...args);
|
|
111
|
+
};
|
|
112
|
+
function _setGlobal(key, value, setGlobal = true) {
|
|
113
|
+
globals.set(key, value);
|
|
114
|
+
if (setGlobal) {
|
|
115
|
+
globalThis[key] = value;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
119
|
+
0 && (module.exports = {
|
|
120
|
+
$,
|
|
121
|
+
$$,
|
|
122
|
+
_setGlobal,
|
|
123
|
+
browser,
|
|
124
|
+
driver,
|
|
125
|
+
expect,
|
|
126
|
+
multiremotebrowser
|
|
127
|
+
});
|
package/build/index.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
/// <reference path="../types.d.ts" />
|
|
2
|
-
|
|
3
1
|
type SupportedGlobals = 'browser' | 'driver' | 'multiremotebrowser' | '$' | '$$' | 'expect';
|
|
4
2
|
declare global {
|
|
5
3
|
var _wdioGlobals: Map<SupportedGlobals, any>;
|
|
4
|
+
namespace WebdriverIO {
|
|
5
|
+
interface Browser {
|
|
6
|
+
}
|
|
7
|
+
interface Element {
|
|
8
|
+
}
|
|
9
|
+
interface MultiRemoteBrowser {
|
|
10
|
+
}
|
|
11
|
+
}
|
|
6
12
|
}
|
|
7
13
|
export declare const browser: WebdriverIO.Browser;
|
|
8
14
|
export declare const driver: WebdriverIO.Browser;
|
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":"AAEA,KAAK,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,oBAAoB,GAAG,GAAG,GAAG,IAAI,GAAG,QAAQ,CAAA;AAE3F,OAAO,CAAC,MAAM,CAAC;IAEX,IAAI,YAAY,EAAE,GAAG,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAA;IAC5C,UAAU,WAAW,CAAC;QAClB,UAAU,OAAO;SAAG;QACpB,UAAU,OAAO;SAAG;QACpB,UAAU,kBAAkB;SAAG;KAClC;CACJ;AA6BD,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;AAED,eAAO,MAAM,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,CAKtC,CAAA;AAED,eAAO,MAAM,EAAE,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAKxC,CAAA;AACD,eAAO,MAAM,MAAM,EAAE,iBAAiB,CAAC,MAKT,CAAA;AAsC9B;;;;;GAKG;AACH,wBAAgB,UAAU,CAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,UAAO,QAM9E"}
|
package/build/index.js
CHANGED
|
@@ -1,93 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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();
|
|
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.';
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var globals = globalThis._wdioGlobals = globalThis._wdioGlobals || /* @__PURE__ */ new Map();
|
|
3
|
+
var 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.`;
|
|
11
4
|
function proxyHandler(key) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
16
|
-
}
|
|
17
|
-
const receiver = globals.get(key);
|
|
18
|
-
const field = receiver[prop];
|
|
19
|
-
return typeof field === 'function'
|
|
20
|
-
? field.bind(receiver)
|
|
21
|
-
: field;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export const browser = new Proxy(class Browser {
|
|
26
|
-
}, proxyHandler('browser'));
|
|
27
|
-
export const driver = new Proxy(class Browser {
|
|
28
|
-
}, proxyHandler('driver'));
|
|
29
|
-
export const multiremotebrowser = new Proxy(class Browser {
|
|
30
|
-
}, proxyHandler('multiremotebrowser'));
|
|
31
|
-
export const $ = (...args) => {
|
|
32
|
-
if (!globals.has('$')) {
|
|
5
|
+
return {
|
|
6
|
+
get: (self, prop) => {
|
|
7
|
+
if (!globals.has(key)) {
|
|
33
8
|
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
9
|
+
}
|
|
10
|
+
const receiver = globals.get(key);
|
|
11
|
+
const field = receiver[prop];
|
|
12
|
+
return typeof field === "function" ? field.bind(receiver) : field;
|
|
34
13
|
}
|
|
35
|
-
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
var browser = new Proxy(
|
|
17
|
+
class Browser {
|
|
18
|
+
},
|
|
19
|
+
proxyHandler("browser")
|
|
20
|
+
);
|
|
21
|
+
var driver = new Proxy(
|
|
22
|
+
class Browser2 {
|
|
23
|
+
},
|
|
24
|
+
proxyHandler("driver")
|
|
25
|
+
);
|
|
26
|
+
var multiremotebrowser = new Proxy(
|
|
27
|
+
class Browser3 {
|
|
28
|
+
},
|
|
29
|
+
proxyHandler("multiremotebrowser")
|
|
30
|
+
);
|
|
31
|
+
var $ = (...args) => {
|
|
32
|
+
if (!globals.has("$")) {
|
|
33
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
34
|
+
}
|
|
35
|
+
return globals.get("$")(...args);
|
|
36
36
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
var $$ = (...args) => {
|
|
38
|
+
if (!globals.has("$$")) {
|
|
39
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
40
|
+
}
|
|
41
|
+
return globals.get("$$")(...args);
|
|
42
42
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
43
|
+
var expect = (...args) => {
|
|
44
|
+
if (!globals.has("expect")) {
|
|
45
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
46
|
+
}
|
|
47
|
+
return globals.get("expect")(...args);
|
|
48
|
+
};
|
|
49
|
+
var ASYNC_MATCHERS = [
|
|
50
|
+
"any",
|
|
51
|
+
"anything",
|
|
52
|
+
"arrayContaining",
|
|
53
|
+
"objectContaining",
|
|
54
|
+
"stringContaining",
|
|
55
|
+
"stringMatching"
|
|
56
56
|
];
|
|
57
57
|
for (const matcher of ASYNC_MATCHERS) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
expect[matcher] = (...args) => {
|
|
59
|
+
if (!globals.has("expect")) {
|
|
60
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
61
|
+
}
|
|
62
|
+
return globals.get("expect")[matcher](...args);
|
|
63
|
+
};
|
|
64
64
|
}
|
|
65
65
|
expect.not = ASYNC_MATCHERS.reduce((acc, matcher) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
acc[matcher] = (...args) => {
|
|
67
|
+
if (!globals.has("expect")) {
|
|
68
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
69
|
+
}
|
|
70
|
+
return globals.get("expect").not[matcher](...args);
|
|
71
|
+
};
|
|
72
|
+
return acc;
|
|
73
73
|
}, {});
|
|
74
74
|
expect.extend = (...args) => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
if (!globals.has("expect")) {
|
|
76
|
+
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
77
|
+
}
|
|
78
|
+
const expect2 = globals.get("expect");
|
|
79
|
+
return expect2.extend(...args);
|
|
80
80
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
*/
|
|
87
|
-
export function _setGlobal(key, value, setGlobal = true) {
|
|
88
|
-
globals.set(key, value);
|
|
89
|
-
if (setGlobal) {
|
|
90
|
-
// @ts-expect-error
|
|
91
|
-
globalThis[key] = value;
|
|
92
|
-
}
|
|
81
|
+
function _setGlobal(key, value, setGlobal = true) {
|
|
82
|
+
globals.set(key, value);
|
|
83
|
+
if (setGlobal) {
|
|
84
|
+
globalThis[key] = value;
|
|
85
|
+
}
|
|
93
86
|
}
|
|
87
|
+
export {
|
|
88
|
+
$,
|
|
89
|
+
$$,
|
|
90
|
+
_setGlobal,
|
|
91
|
+
browser,
|
|
92
|
+
driver,
|
|
93
|
+
expect,
|
|
94
|
+
multiremotebrowser
|
|
95
|
+
};
|
package/package.json
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/globals",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.1",
|
|
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": "./
|
|
8
|
+
"main": "./build/index.cjs",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"module": "./build/index.js",
|
|
11
11
|
"exports": {
|
|
12
|
-
".":
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"./
|
|
19
|
-
|
|
20
|
-
"./types": "./types.d.ts",
|
|
21
|
-
"./package.json": "./package.json"
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./build/index.d.ts",
|
|
14
|
+
"import": "./build/index.js",
|
|
15
|
+
"require": "./build/index.cjs"
|
|
16
|
+
},
|
|
17
|
+
"./types": {
|
|
18
|
+
"types": "./types.d.ts"
|
|
19
|
+
}
|
|
22
20
|
},
|
|
23
21
|
"types": "./build/index.d.ts",
|
|
24
22
|
"typeScriptVersion": "3.8.3",
|
|
@@ -42,8 +40,8 @@
|
|
|
42
40
|
"access": "public"
|
|
43
41
|
},
|
|
44
42
|
"optionalDependencies": {
|
|
45
|
-
"expect-webdriverio": "
|
|
46
|
-
"webdriverio": "9.0.
|
|
43
|
+
"expect-webdriverio": "5.0.0-alpha.2",
|
|
44
|
+
"webdriverio": "9.0.1"
|
|
47
45
|
},
|
|
48
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "2a869e5661b2f867d00997c8a17ed0efee0fd15b"
|
|
49
47
|
}
|
package/types.d.ts
CHANGED
|
@@ -11,9 +11,10 @@ declare module NodeJS {
|
|
|
11
11
|
|
|
12
12
|
declare function $(...args: Parameters<WebdriverIO.Browser['$']>): ReturnType<WebdriverIO.Browser['$']>
|
|
13
13
|
declare function $$(...args: Parameters<WebdriverIO.Browser['$$']>): ReturnType<WebdriverIO.Browser['$$']>
|
|
14
|
+
declare var multiremotebrowser: WebdriverIO.MultiRemoteBrowser
|
|
14
15
|
declare var browser: WebdriverIO.Browser
|
|
15
16
|
declare var driver: WebdriverIO.Browser
|
|
16
|
-
declare var
|
|
17
|
+
declare var expect: ExpectType
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* custom environment primitives for WebdriverIO when running in a browser
|
package/cjs/index.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
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
|
-
const receiver = globals.get(key);
|
|
21
|
-
const field = receiver[prop];
|
|
22
|
-
return typeof field === 'function'
|
|
23
|
-
? field.bind(receiver)
|
|
24
|
-
: field;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
exports.browser = new Proxy(class Browser {
|
|
29
|
-
}, proxyHandler('browser'));
|
|
30
|
-
exports.driver = new Proxy(class Browser {
|
|
31
|
-
}, proxyHandler('driver'));
|
|
32
|
-
exports.multiremotebrowser = new Proxy(class Browser {
|
|
33
|
-
}, proxyHandler('multiremotebrowser'));
|
|
34
|
-
const $ = (...args) => {
|
|
35
|
-
if (!globals.has('$')) {
|
|
36
|
-
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
37
|
-
}
|
|
38
|
-
return globals.get('$')(...args);
|
|
39
|
-
};
|
|
40
|
-
exports.$ = $;
|
|
41
|
-
const $$ = (...args) => {
|
|
42
|
-
if (!globals.has('$$')) {
|
|
43
|
-
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
44
|
-
}
|
|
45
|
-
return globals.get('$$')(...args);
|
|
46
|
-
};
|
|
47
|
-
exports.$$ = $$;
|
|
48
|
-
exports.expect = ((...args) => {
|
|
49
|
-
if (!globals.has('expect')) {
|
|
50
|
-
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
51
|
-
}
|
|
52
|
-
return globals.get('expect')(...args);
|
|
53
|
-
});
|
|
54
|
-
const ASYNC_MATCHERS = [
|
|
55
|
-
'any',
|
|
56
|
-
'anything',
|
|
57
|
-
'arrayContaining',
|
|
58
|
-
'objectContaining',
|
|
59
|
-
'stringContaining',
|
|
60
|
-
'stringMatching',
|
|
61
|
-
];
|
|
62
|
-
for (const matcher of ASYNC_MATCHERS) {
|
|
63
|
-
exports.expect[matcher] = (...args) => {
|
|
64
|
-
if (!globals.has('expect')) {
|
|
65
|
-
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
66
|
-
}
|
|
67
|
-
return globals.get('expect')[matcher](...args);
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
exports.expect.not = ASYNC_MATCHERS.reduce((acc, matcher) => {
|
|
71
|
-
acc[matcher] = (...args) => {
|
|
72
|
-
if (!globals.has('expect')) {
|
|
73
|
-
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
74
|
-
}
|
|
75
|
-
return globals.get('expect').not[matcher](...args);
|
|
76
|
-
};
|
|
77
|
-
return acc;
|
|
78
|
-
}, {});
|
|
79
|
-
exports.expect.extend = (...args) => {
|
|
80
|
-
if (!globals.has('expect')) {
|
|
81
|
-
throw new Error(GLOBALS_ERROR_MESSAGE);
|
|
82
|
-
}
|
|
83
|
-
const expect = globals.get('expect');
|
|
84
|
-
return expect.extend(...args);
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* allows to set global property to be imported and used later on
|
|
88
|
-
* @param key global key
|
|
89
|
-
* @param value actual value to be returned
|
|
90
|
-
* @private
|
|
91
|
-
*/
|
|
92
|
-
function _setGlobal(key, value, setGlobal = true) {
|
|
93
|
-
globals.set(key, value);
|
|
94
|
-
if (setGlobal) {
|
|
95
|
-
// @ts-expect-error
|
|
96
|
-
globalThis[key] = value;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports._setGlobal = _setGlobal;
|
package/cjs/package.json
DELETED
/package/{LICENSE-MIT → LICENSE}
RENAMED
|
File without changes
|