@appium/test-support 4.1.0 → 4.1.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/lib/mock-utils.d.ts.map +1 -1
- package/build/lib/mock-utils.js +35 -35
- package/build/lib/mock-utils.js.map +1 -1
- package/build/lib/sandbox-utils.d.ts.map +1 -1
- package/build/lib/sandbox-utils.js +34 -34
- package/build/lib/sandbox-utils.js.map +1 -1
- package/lib/mock-utils.js +37 -37
- package/lib/sandbox-utils.js +36 -36
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-utils.d.ts","sourceRoot":"","sources":["../../lib/mock-utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mock-utils.d.ts","sourceRoot":"","sources":["../../lib/mock-utils.js"],"names":[],"mappings":"AAgEA;;;;;;;;;;;;GAYG;AACH,oCAJW,MAAM,CAAC,MAAM,GAAC,MAAM,EAAC,GAAG,CAAC,MACzB,CAAC,KAAK,gBAAW,KAAK,IAAI,GACxB,MAAM,IAAI,CAetB;AAED;;;;GAIG;AACH,yDAEC;AAjGD;;;;GAIG;AACH,uBAJkC,KAAK,SAAzB,MAAM,CAAC,MAAM,EAAC,GAAG,CAAE;IAiB/B;;;OAGG;IACH,sBAFW,YAAY,EAItB;IAlBD;;;OAGG;IACH,SAFU,YAAY,GAAC,SAAS,CAExB;IAgBR;;OAEG;IACH,sBAFW,KAAK,QAYf;IAED;;OAEG;IACH,eAOC;IAED,cAMC;;CACF;2BAwCY,OAAO,OAAO,EAAE,YAAY"}
|
package/build/lib/mock-utils.js
CHANGED
|
@@ -7,41 +7,6 @@ exports.MockStore = void 0;
|
|
|
7
7
|
exports.withMocks = withMocks;
|
|
8
8
|
exports.verifyMocks = verifyMocks;
|
|
9
9
|
const sinon_1 = __importDefault(require("sinon"));
|
|
10
|
-
/**
|
|
11
|
-
* Creates a function which creates Mocha "before each" and "after each" hooks to
|
|
12
|
-
* automatically mock (and un-mock) the mocks provided by `libs`.
|
|
13
|
-
*
|
|
14
|
-
* The values of `libs` are provided directly to {@linkcode SinonSandbox.mock}.
|
|
15
|
-
*
|
|
16
|
-
* _Synchronously_ calls `fn` with the {@linkcode MockStore} after hooks have been created, but not before they have been run.
|
|
17
|
-
*
|
|
18
|
-
* @deprecated Use `sinon.createSandbox()` directly with Mocha `beforeEach`/`afterEach` hooks instead.
|
|
19
|
-
* @param {Record<string|symbol,any>} mockDefs
|
|
20
|
-
* @param {(mocks: MockStore) => void} fn
|
|
21
|
-
* @returns {() => void}
|
|
22
|
-
*/
|
|
23
|
-
function withMocks(mockDefs, fn) {
|
|
24
|
-
return () => {
|
|
25
|
-
const mocks = new MockStore();
|
|
26
|
-
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
27
|
-
beforeEach(function withMocksBeforeEach() {
|
|
28
|
-
mocks.createMocks(mockDefs);
|
|
29
|
-
});
|
|
30
|
-
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
31
|
-
afterEach(function withMocksAfterEach() {
|
|
32
|
-
mocks.reset();
|
|
33
|
-
});
|
|
34
|
-
fn(mocks);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Convenience function for calling `mocks.verify()`.
|
|
39
|
-
* @deprecated Call `sandbox.verify()` directly on your sinon sandbox instead.
|
|
40
|
-
* @param {MockStore} mocks - Returned by callback from {@linkcode withMocks}
|
|
41
|
-
*/
|
|
42
|
-
function verifyMocks(mocks) {
|
|
43
|
-
mocks.verify();
|
|
44
|
-
}
|
|
45
10
|
/**
|
|
46
11
|
* @template {Record<string,any>} Mocks
|
|
47
12
|
* @extends {Mocks}
|
|
@@ -97,6 +62,41 @@ class MockStore {
|
|
|
97
62
|
}
|
|
98
63
|
}
|
|
99
64
|
exports.MockStore = MockStore;
|
|
65
|
+
/**
|
|
66
|
+
* Creates a function which creates Mocha "before each" and "after each" hooks to
|
|
67
|
+
* automatically mock (and un-mock) the mocks provided by `libs`.
|
|
68
|
+
*
|
|
69
|
+
* The values of `libs` are provided directly to {@linkcode SinonSandbox.mock}.
|
|
70
|
+
*
|
|
71
|
+
* _Synchronously_ calls `fn` with the {@linkcode MockStore} after hooks have been created, but not before they have been run.
|
|
72
|
+
*
|
|
73
|
+
* @deprecated Use `sinon.createSandbox()` directly with Mocha `beforeEach`/`afterEach` hooks instead.
|
|
74
|
+
* @param {Record<string|symbol,any>} mockDefs
|
|
75
|
+
* @param {(mocks: MockStore) => void} fn
|
|
76
|
+
* @returns {() => void}
|
|
77
|
+
*/
|
|
78
|
+
function withMocks(mockDefs, fn) {
|
|
79
|
+
return () => {
|
|
80
|
+
const mocks = new MockStore();
|
|
81
|
+
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
82
|
+
beforeEach(function withMocksBeforeEach() {
|
|
83
|
+
mocks.createMocks(mockDefs);
|
|
84
|
+
});
|
|
85
|
+
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
86
|
+
afterEach(function withMocksAfterEach() {
|
|
87
|
+
mocks.reset();
|
|
88
|
+
});
|
|
89
|
+
fn(mocks);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Convenience function for calling `mocks.verify()`.
|
|
94
|
+
* @deprecated Call `sandbox.verify()` directly on your sinon sandbox instead.
|
|
95
|
+
* @param {MockStore} mocks - Returned by callback from {@linkcode withMocks}
|
|
96
|
+
*/
|
|
97
|
+
function verifyMocks(mocks) {
|
|
98
|
+
mocks.verify();
|
|
99
|
+
}
|
|
100
100
|
/**
|
|
101
101
|
* @typedef {import('sinon').SinonSandbox} SinonSandbox
|
|
102
102
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-utils.js","sourceRoot":"","sources":["../../lib/mock-utils.js"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"mock-utils.js","sourceRoot":"","sources":["../../lib/mock-utils.js"],"names":[],"mappings":";;;;;;AA6EA,8BAaC;AAOD,kCAEC;AAnGD,kDAA0B;AAE1B;;;;GAIG;AACH,MAAa,SAAS;IACpB;;;OAGG;IACH,OAAO,CAAC;IAER;;;OAGG;IACH,MAAM,CAAC;IAEP;;;OAGG;IACH,YAAY,OAAO;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,QAAQ;QAClB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,cAAc,CAAC,kDAAkD,CAAC,CAAC;QAC/E,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,eAAK,CAAC,aAAa,EAAE,CAAC;QACrD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACpD,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,cAAc,CACtB,yEAAyE,CAC1E,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;IAED,KAAK;QACH,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,CAAC;YACjD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;CACF;AAvDD,8BAuDC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,SAAS,CAAC,QAAQ,EAAE,EAAE;IACpC,OAAO,GAAG,EAAE;QACV,MAAM,KAAK,GAAG,IAAI,SAAS,EAAE,CAAC;QAC9B,oDAAoD;QACpD,UAAU,CAAC,SAAS,mBAAmB;YACrC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;QACH,oDAAoD;QACpD,SAAS,CAAC,SAAS,kBAAkB;YACnC,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,KAAK,CAAC,CAAC;IACZ,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAgB,WAAW,CAAC,KAAK;IAC/B,KAAK,CAAC,MAAM,EAAE,CAAC;AACjB,CAAC;AAED;;GAEG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-utils.d.ts","sourceRoot":"","sources":["../../lib/sandbox-utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sandbox-utils.d.ts","sourceRoot":"","sources":["../../lib/sandbox-utils.js"],"names":[],"mappings":"AAiDA;;;;;;GAMG;AACH,4BAN8D,KAAK,SAArD,MAAM,CAAC,MAAM,EAAC,GAAG,CAAC,GAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAC,GAAG,CAAC,CAAA;CAAE,YAElD,KAAK,MACL,CAAC,YAAY,mBAAc,KAAK,IAAI,GAClC,MAAM,IAAI,CAoBtB;AAED;;;;GAIG;AACH,0CAFW,kCAAsB,QAIhC;AA/ED;;;GAGG;AACH,0BAHkC,KAAK,SAAzB,MAAM,CAAC,MAAM,EAAC,GAAG,CAAE;IAU/B;;;OAGG;IACH,sBAFW,YAAY,EAItB;IAZD,4CAA4C;IAC5C,OADW,SAAS,CAAC,MAAM,CAAC,MAAM,EAAC,GAAG,CAAC,CAAC,CAClC;IAEN,qCAAqC;IACrC,SADW,YAAY,GAAC,SAAS,CACzB;IAUR;;OAEG;IACH,sBAFW,KAAK,QAKf;IAED;;OAEG;IACH,eAOC;IAED,cAGC;CACF;2BAuCY,OAAO,OAAO,EAAE,YAAY;0BApFjB,cAAc"}
|
|
@@ -9,40 +9,6 @@ exports.verifySandbox = verifySandbox;
|
|
|
9
9
|
const sinon_1 = __importDefault(require("sinon"));
|
|
10
10
|
const lodash_1 = __importDefault(require("lodash"));
|
|
11
11
|
const mock_utils_1 = require("./mock-utils");
|
|
12
|
-
/**
|
|
13
|
-
* @template {Record<string,any>|{mocks: Record<string,any>}} Mocks
|
|
14
|
-
* @deprecated Use `sinon.createSandbox()` directly with Mocha `beforeEach`/`afterEach` hooks instead.
|
|
15
|
-
* @param {Mocks} mockDefs
|
|
16
|
-
* @param {(sandboxStore: SandboxStore) => void} fn
|
|
17
|
-
* @returns {() => void}
|
|
18
|
-
*/
|
|
19
|
-
function withSandbox(mockDefs, fn) {
|
|
20
|
-
// backwards-compat
|
|
21
|
-
if (!lodash_1.default.isEmpty(mockDefs.mocks)) {
|
|
22
|
-
mockDefs = mockDefs.mocks;
|
|
23
|
-
}
|
|
24
|
-
return () => {
|
|
25
|
-
/** @type {SandboxStore} */
|
|
26
|
-
const sbx = new SandboxStore();
|
|
27
|
-
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
28
|
-
beforeEach(function beforeEach() {
|
|
29
|
-
sbx.createSandbox(mockDefs);
|
|
30
|
-
});
|
|
31
|
-
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
32
|
-
afterEach(function afterEach() {
|
|
33
|
-
sbx.reset();
|
|
34
|
-
});
|
|
35
|
-
fn(sbx);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Convenience function for calling {@linkcode SandboxStore.verify}.
|
|
40
|
-
* @deprecated Call `sandbox.verify()` directly on your sinon sandbox instead.
|
|
41
|
-
* @param {SandboxStore|MockStore} sbxOrMocks
|
|
42
|
-
*/
|
|
43
|
-
function verifySandbox(sbxOrMocks) {
|
|
44
|
-
sbxOrMocks.verify();
|
|
45
|
-
}
|
|
46
12
|
/**
|
|
47
13
|
* @template {Record<string,any>} Mocks
|
|
48
14
|
* @deprecated Use `sinon.createSandbox()` directly instead.
|
|
@@ -81,6 +47,40 @@ class SandboxStore {
|
|
|
81
47
|
}
|
|
82
48
|
}
|
|
83
49
|
exports.SandboxStore = SandboxStore;
|
|
50
|
+
/**
|
|
51
|
+
* @template {Record<string,any>|{mocks: Record<string,any>}} Mocks
|
|
52
|
+
* @deprecated Use `sinon.createSandbox()` directly with Mocha `beforeEach`/`afterEach` hooks instead.
|
|
53
|
+
* @param {Mocks} mockDefs
|
|
54
|
+
* @param {(sandboxStore: SandboxStore) => void} fn
|
|
55
|
+
* @returns {() => void}
|
|
56
|
+
*/
|
|
57
|
+
function withSandbox(mockDefs, fn) {
|
|
58
|
+
// backwards-compat
|
|
59
|
+
if (!lodash_1.default.isEmpty(mockDefs.mocks)) {
|
|
60
|
+
mockDefs = mockDefs.mocks;
|
|
61
|
+
}
|
|
62
|
+
return () => {
|
|
63
|
+
/** @type {SandboxStore} */
|
|
64
|
+
const sbx = new SandboxStore();
|
|
65
|
+
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
66
|
+
beforeEach(function beforeEach() {
|
|
67
|
+
sbx.createSandbox(mockDefs);
|
|
68
|
+
});
|
|
69
|
+
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
70
|
+
afterEach(function afterEach() {
|
|
71
|
+
sbx.reset();
|
|
72
|
+
});
|
|
73
|
+
fn(sbx);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Convenience function for calling {@linkcode SandboxStore.verify}.
|
|
78
|
+
* @deprecated Call `sandbox.verify()` directly on your sinon sandbox instead.
|
|
79
|
+
* @param {SandboxStore|MockStore} sbxOrMocks
|
|
80
|
+
*/
|
|
81
|
+
function verifySandbox(sbxOrMocks) {
|
|
82
|
+
sbxOrMocks.verify();
|
|
83
|
+
}
|
|
84
84
|
/**
|
|
85
85
|
* @typedef {import('sinon').SinonSandbox} SinonSandbox
|
|
86
86
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-utils.js","sourceRoot":"","sources":["../../lib/sandbox-utils.js"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"sandbox-utils.js","sourceRoot":"","sources":["../../lib/sandbox-utils.js"],"names":[],"mappings":";;;;;;AAwDA,kCAkBC;AAOD,sCAEC;AAnFD,kDAA0B;AAC1B,oDAAuB;AACvB,6CAAuC;AAEvC;;;GAGG;AACH,MAAa,YAAY;IACvB,4CAA4C;IAC5C,KAAK,CAAC;IAEN,qCAAqC;IACrC,OAAO,CAAC;IAER;;;OAGG;IACH,YAAY,OAAO;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,KAAK,GAAG,oBAAoB,CAAC,CAAC,EAAE,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,eAAK,CAAC,aAAa,EAAE,CAAC;QACrD,IAAI,CAAC,KAAK,GAAG,IAAI,sBAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,cAAc,CACtB,yEAAyE,CAC1E,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAvCD,oCAuCC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,QAAQ,EAAE,EAAE;IACtC,mBAAmB;IACnB,IAAI,CAAC,gBAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC5B,CAAC;IACD,OAAO,GAAG,EAAE;QACV,2BAA2B;QAC3B,MAAM,GAAG,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,oDAAoD;QACpD,UAAU,CAAC,SAAS,UAAU;YAC5B,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;QACH,oDAAoD;QACpD,SAAS,CAAC,SAAS,SAAS;YAC1B,GAAG,CAAC,KAAK,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,GAAG,CAAC,CAAC;IACV,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,UAAU;IACtC,UAAU,CAAC,MAAM,EAAE,CAAC;AACtB,CAAC;AAED;;GAEG"}
|
package/lib/mock-utils.js
CHANGED
|
@@ -1,42 +1,5 @@
|
|
|
1
1
|
import sinon from 'sinon';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Creates a function which creates Mocha "before each" and "after each" hooks to
|
|
5
|
-
* automatically mock (and un-mock) the mocks provided by `libs`.
|
|
6
|
-
*
|
|
7
|
-
* The values of `libs` are provided directly to {@linkcode SinonSandbox.mock}.
|
|
8
|
-
*
|
|
9
|
-
* _Synchronously_ calls `fn` with the {@linkcode MockStore} after hooks have been created, but not before they have been run.
|
|
10
|
-
*
|
|
11
|
-
* @deprecated Use `sinon.createSandbox()` directly with Mocha `beforeEach`/`afterEach` hooks instead.
|
|
12
|
-
* @param {Record<string|symbol,any>} mockDefs
|
|
13
|
-
* @param {(mocks: MockStore) => void} fn
|
|
14
|
-
* @returns {() => void}
|
|
15
|
-
*/
|
|
16
|
-
export function withMocks(mockDefs, fn) {
|
|
17
|
-
return () => {
|
|
18
|
-
const mocks = new MockStore();
|
|
19
|
-
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
20
|
-
beforeEach(function withMocksBeforeEach() {
|
|
21
|
-
mocks.createMocks(mockDefs);
|
|
22
|
-
});
|
|
23
|
-
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
24
|
-
afterEach(function withMocksAfterEach() {
|
|
25
|
-
mocks.reset();
|
|
26
|
-
});
|
|
27
|
-
fn(mocks);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Convenience function for calling `mocks.verify()`.
|
|
33
|
-
* @deprecated Call `sandbox.verify()` directly on your sinon sandbox instead.
|
|
34
|
-
* @param {MockStore} mocks - Returned by callback from {@linkcode withMocks}
|
|
35
|
-
*/
|
|
36
|
-
export function verifyMocks(mocks) {
|
|
37
|
-
mocks.verify();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
3
|
/**
|
|
41
4
|
* @template {Record<string,any>} Mocks
|
|
42
5
|
* @extends {Mocks}
|
|
@@ -99,6 +62,43 @@ export class MockStore {
|
|
|
99
62
|
}
|
|
100
63
|
}
|
|
101
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Creates a function which creates Mocha "before each" and "after each" hooks to
|
|
67
|
+
* automatically mock (and un-mock) the mocks provided by `libs`.
|
|
68
|
+
*
|
|
69
|
+
* The values of `libs` are provided directly to {@linkcode SinonSandbox.mock}.
|
|
70
|
+
*
|
|
71
|
+
* _Synchronously_ calls `fn` with the {@linkcode MockStore} after hooks have been created, but not before they have been run.
|
|
72
|
+
*
|
|
73
|
+
* @deprecated Use `sinon.createSandbox()` directly with Mocha `beforeEach`/`afterEach` hooks instead.
|
|
74
|
+
* @param {Record<string|symbol,any>} mockDefs
|
|
75
|
+
* @param {(mocks: MockStore) => void} fn
|
|
76
|
+
* @returns {() => void}
|
|
77
|
+
*/
|
|
78
|
+
export function withMocks(mockDefs, fn) {
|
|
79
|
+
return () => {
|
|
80
|
+
const mocks = new MockStore();
|
|
81
|
+
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
82
|
+
beforeEach(function withMocksBeforeEach() {
|
|
83
|
+
mocks.createMocks(mockDefs);
|
|
84
|
+
});
|
|
85
|
+
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
86
|
+
afterEach(function withMocksAfterEach() {
|
|
87
|
+
mocks.reset();
|
|
88
|
+
});
|
|
89
|
+
fn(mocks);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Convenience function for calling `mocks.verify()`.
|
|
95
|
+
* @deprecated Call `sandbox.verify()` directly on your sinon sandbox instead.
|
|
96
|
+
* @param {MockStore} mocks - Returned by callback from {@linkcode withMocks}
|
|
97
|
+
*/
|
|
98
|
+
export function verifyMocks(mocks) {
|
|
99
|
+
mocks.verify();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
102
|
/**
|
|
103
103
|
* @typedef {import('sinon').SinonSandbox} SinonSandbox
|
|
104
104
|
*/
|
package/lib/sandbox-utils.js
CHANGED
|
@@ -2,42 +2,6 @@ import sinon from 'sinon';
|
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
import {MockStore} from './mock-utils';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* @template {Record<string,any>|{mocks: Record<string,any>}} Mocks
|
|
7
|
-
* @deprecated Use `sinon.createSandbox()` directly with Mocha `beforeEach`/`afterEach` hooks instead.
|
|
8
|
-
* @param {Mocks} mockDefs
|
|
9
|
-
* @param {(sandboxStore: SandboxStore) => void} fn
|
|
10
|
-
* @returns {() => void}
|
|
11
|
-
*/
|
|
12
|
-
export function withSandbox(mockDefs, fn) {
|
|
13
|
-
// backwards-compat
|
|
14
|
-
if (!_.isEmpty(mockDefs.mocks)) {
|
|
15
|
-
mockDefs = mockDefs.mocks;
|
|
16
|
-
}
|
|
17
|
-
return () => {
|
|
18
|
-
/** @type {SandboxStore} */
|
|
19
|
-
const sbx = new SandboxStore();
|
|
20
|
-
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
21
|
-
beforeEach(function beforeEach() {
|
|
22
|
-
sbx.createSandbox(mockDefs);
|
|
23
|
-
});
|
|
24
|
-
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
25
|
-
afterEach(function afterEach() {
|
|
26
|
-
sbx.reset();
|
|
27
|
-
});
|
|
28
|
-
fn(sbx);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Convenience function for calling {@linkcode SandboxStore.verify}.
|
|
34
|
-
* @deprecated Call `sandbox.verify()` directly on your sinon sandbox instead.
|
|
35
|
-
* @param {SandboxStore|MockStore} sbxOrMocks
|
|
36
|
-
*/
|
|
37
|
-
export function verifySandbox(sbxOrMocks) {
|
|
38
|
-
sbxOrMocks.verify();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
5
|
/**
|
|
42
6
|
* @template {Record<string,any>} Mocks
|
|
43
7
|
* @deprecated Use `sinon.createSandbox()` directly instead.
|
|
@@ -83,6 +47,42 @@ export class SandboxStore {
|
|
|
83
47
|
}
|
|
84
48
|
}
|
|
85
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @template {Record<string,any>|{mocks: Record<string,any>}} Mocks
|
|
52
|
+
* @deprecated Use `sinon.createSandbox()` directly with Mocha `beforeEach`/`afterEach` hooks instead.
|
|
53
|
+
* @param {Mocks} mockDefs
|
|
54
|
+
* @param {(sandboxStore: SandboxStore) => void} fn
|
|
55
|
+
* @returns {() => void}
|
|
56
|
+
*/
|
|
57
|
+
export function withSandbox(mockDefs, fn) {
|
|
58
|
+
// backwards-compat
|
|
59
|
+
if (!_.isEmpty(mockDefs.mocks)) {
|
|
60
|
+
mockDefs = mockDefs.mocks;
|
|
61
|
+
}
|
|
62
|
+
return () => {
|
|
63
|
+
/** @type {SandboxStore} */
|
|
64
|
+
const sbx = new SandboxStore();
|
|
65
|
+
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
66
|
+
beforeEach(function beforeEach() {
|
|
67
|
+
sbx.createSandbox(mockDefs);
|
|
68
|
+
});
|
|
69
|
+
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
70
|
+
afterEach(function afterEach() {
|
|
71
|
+
sbx.reset();
|
|
72
|
+
});
|
|
73
|
+
fn(sbx);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Convenience function for calling {@linkcode SandboxStore.verify}.
|
|
79
|
+
* @deprecated Call `sandbox.verify()` directly on your sinon sandbox instead.
|
|
80
|
+
* @param {SandboxStore|MockStore} sbxOrMocks
|
|
81
|
+
*/
|
|
82
|
+
export function verifySandbox(sbxOrMocks) {
|
|
83
|
+
sbxOrMocks.verify();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
86
|
/**
|
|
87
87
|
* @typedef {import('sinon').SinonSandbox} SinonSandbox
|
|
88
88
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/test-support",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "A collection of test utilities used across Appium packages",
|
|
5
5
|
"deprecated": "This module is deprecated. Use sinon directly instead (e.g., sinon.createSandbox() with Mocha hooks).",
|
|
6
6
|
"keywords": [
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@appium/support": "7.1.
|
|
50
|
+
"@appium/support": "7.1.1",
|
|
51
51
|
"@colors/colors": "1.6.0",
|
|
52
52
|
"bluebird": "3.7.2",
|
|
53
53
|
"lodash": "4.18.1",
|
|
54
54
|
"loud-rejection": "2.2.0",
|
|
55
|
-
"sinon": "21.
|
|
55
|
+
"sinon": "21.1.2"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": "^20.19.0 || ^22.12.0 || >=24.0.0",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "17f84265d10944fec06ae7684ae8ad77d1224b50"
|
|
65
65
|
}
|