@fluidframework/test-utils 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229
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/.eslintrc.js +8 -10
- package/README.md +41 -11
- package/api-extractor.json +2 -2
- package/dist/DriverWrappers.d.ts.map +1 -1
- package/dist/DriverWrappers.js.map +1 -1
- package/dist/TestConfigs.d.ts.map +1 -1
- package/dist/TestConfigs.js +3 -4
- package/dist/TestConfigs.js.map +1 -1
- package/dist/TestSummaryUtils.d.ts +20 -4
- package/dist/TestSummaryUtils.d.ts.map +1 -1
- package/dist/TestSummaryUtils.js +41 -33
- package/dist/TestSummaryUtils.js.map +1 -1
- package/dist/containerUtils.d.ts +29 -0
- package/dist/containerUtils.d.ts.map +1 -0
- package/dist/containerUtils.js +45 -0
- package/dist/containerUtils.js.map +1 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/loaderContainerTracker.d.ts +3 -9
- package/dist/loaderContainerTracker.d.ts.map +1 -1
- package/dist/loaderContainerTracker.js +45 -47
- package/dist/loaderContainerTracker.js.map +1 -1
- package/dist/localCodeLoader.d.ts.map +1 -1
- package/dist/localCodeLoader.js.map +1 -1
- package/dist/localLoader.d.ts.map +1 -1
- package/dist/localLoader.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js.map +1 -1
- package/dist/testContainerRuntimeFactory.d.ts +2 -2
- package/dist/testContainerRuntimeFactory.d.ts.map +1 -1
- package/dist/testContainerRuntimeFactory.js +3 -3
- package/dist/testContainerRuntimeFactory.js.map +1 -1
- package/dist/testFluidObject.d.ts.map +1 -1
- package/dist/testFluidObject.js +7 -3
- package/dist/testFluidObject.js.map +1 -1
- package/dist/testObjectProvider.d.ts +6 -1
- package/dist/testObjectProvider.d.ts.map +1 -1
- package/dist/testObjectProvider.js +49 -16
- package/dist/testObjectProvider.js.map +1 -1
- package/dist/timeoutUtils.d.ts +11 -2
- package/dist/timeoutUtils.d.ts.map +1 -1
- package/dist/timeoutUtils.js +122 -18
- package/dist/timeoutUtils.js.map +1 -1
- package/package.json +65 -58
- package/prettier.config.cjs +1 -1
- package/src/DriverWrappers.ts +40 -37
- package/src/TestConfigs.ts +7 -7
- package/src/TestSummaryUtils.ts +123 -124
- package/src/containerUtils.ts +48 -0
- package/src/index.ts +24 -23
- package/src/interfaces.ts +10 -7
- package/src/loaderContainerTracker.ts +618 -577
- package/src/localCodeLoader.ts +85 -77
- package/src/localLoader.ts +24 -24
- package/src/packageVersion.ts +1 -1
- package/src/retry.ts +31 -25
- package/src/testContainerRuntimeFactory.ts +59 -56
- package/src/testFluidObject.ts +168 -152
- package/src/testObjectProvider.ts +477 -384
- package/src/timeoutUtils.ts +191 -41
- package/tsconfig.json +9 -12
package/dist/timeoutUtils.js
CHANGED
|
@@ -4,31 +4,107 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.timeoutPromise = exports.
|
|
7
|
+
exports.timeoutPromise = exports.timeoutAwait = exports.defaultTimeoutDurationMs = void 0;
|
|
8
|
+
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
|
+
// @deprecated this value is no longer used
|
|
8
10
|
exports.defaultTimeoutDurationMs = 250;
|
|
11
|
+
// TestTimeout class manage tracking of test timeout. It create a timer when timeout is in effect,
|
|
12
|
+
// and provide a promise that will be reject before the test timeout happen with a `timeBuffer` of 15 ms.
|
|
13
|
+
// Once rejected, a new TestTimeout object will be create for the timeout.
|
|
14
|
+
const timeBuffer = 15; // leave 15 ms leeway for finish processing
|
|
15
|
+
class TestTimeout {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.timeout = 0;
|
|
18
|
+
this.rejected = false;
|
|
19
|
+
this.deferred = new common_utils_1.Deferred();
|
|
20
|
+
// Ignore rejection for timeout promise if no one is waiting for it.
|
|
21
|
+
this.deferred.promise.catch(() => { });
|
|
22
|
+
}
|
|
23
|
+
static reset(runnable) {
|
|
24
|
+
TestTimeout.clear();
|
|
25
|
+
TestTimeout.instance.resetTimer(runnable);
|
|
26
|
+
}
|
|
27
|
+
static clear() {
|
|
28
|
+
if (TestTimeout.instance.rejected) {
|
|
29
|
+
TestTimeout.instance = new TestTimeout();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
TestTimeout.instance.clearTimer();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
static getInstance() {
|
|
36
|
+
return TestTimeout.instance;
|
|
37
|
+
}
|
|
38
|
+
async getPromise() {
|
|
39
|
+
return this.deferred.promise;
|
|
40
|
+
}
|
|
41
|
+
getTimeout() {
|
|
42
|
+
return this.timeout;
|
|
43
|
+
}
|
|
44
|
+
resetTimer(runnable) {
|
|
45
|
+
(0, common_utils_1.assert)(!this.timer, "clearTimer should have been called before reset");
|
|
46
|
+
(0, common_utils_1.assert)(!this.deferred.isCompleted, "can't reset a completed TestTimeout");
|
|
47
|
+
// Check the test timeout setting
|
|
48
|
+
const timeout = runnable.timeout();
|
|
49
|
+
if (!(Number.isFinite(timeout) && timeout > 0)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
// subtract a buffer
|
|
53
|
+
this.timeout = Math.max(timeout - timeBuffer, 1);
|
|
54
|
+
// Set up timer to reject near the test timeout.
|
|
55
|
+
this.timer = setTimeout(() => {
|
|
56
|
+
this.deferred.reject(this);
|
|
57
|
+
this.rejected = true;
|
|
58
|
+
}, this.timeout);
|
|
59
|
+
}
|
|
60
|
+
clearTimer() {
|
|
61
|
+
if (this.timer) {
|
|
62
|
+
clearTimeout(this.timer);
|
|
63
|
+
this.timer = undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
TestTimeout.instance = new TestTimeout();
|
|
68
|
+
// only register if we are running with mocha-test-setup loaded
|
|
69
|
+
if (globalThis.getMochaModule !== undefined) {
|
|
70
|
+
// patching resetTimeout and clearTimeout on the runnable object
|
|
71
|
+
// so we can track when test timeout are enforced
|
|
72
|
+
const mochaModule = globalThis.getMochaModule();
|
|
73
|
+
const runnablePrototype = mochaModule.Runnable.prototype;
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
75
|
+
const oldResetTimeoutFunc = runnablePrototype.resetTimeout;
|
|
76
|
+
runnablePrototype.resetTimeout = function () {
|
|
77
|
+
oldResetTimeoutFunc.call(this);
|
|
78
|
+
TestTimeout.reset(this);
|
|
79
|
+
};
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
81
|
+
const oldClearTimeoutFunc = runnablePrototype.clearTimeout;
|
|
82
|
+
runnablePrototype.clearTimeout = function () {
|
|
83
|
+
TestTimeout.clear();
|
|
84
|
+
oldClearTimeoutFunc.call(this);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
9
87
|
async function timeoutAwait(promise, timeoutOptions = {}) {
|
|
10
88
|
return Promise.race([promise, timeoutPromise(() => { }, timeoutOptions)]);
|
|
11
89
|
}
|
|
12
90
|
exports.timeoutAwait = timeoutAwait;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return timeoutPromise((resolve) => container.once("connected", () => resolve()));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.ensureContainerConnected = ensureContainerConnected;
|
|
19
|
-
async function timeoutPromise(executor, timeoutOptions = {}) {
|
|
91
|
+
// Create a promise based on the timeout options
|
|
92
|
+
async function getTimeoutPromise(executor, timeoutOptions, err) {
|
|
20
93
|
var _a;
|
|
21
|
-
const timeout = timeoutOptions.durationMs !==
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// create the timeout error outside the async task, so its callstack includes
|
|
26
|
-
// the original call site, this makes it easier to debug
|
|
27
|
-
const err = timeoutOptions.reject === false
|
|
28
|
-
? undefined
|
|
29
|
-
: new Error(`${(_a = timeoutOptions.errorMsg) !== null && _a !== void 0 ? _a : "Timed out"}(${timeout}ms)`);
|
|
94
|
+
const timeout = (_a = timeoutOptions.durationMs) !== null && _a !== void 0 ? _a : 0;
|
|
95
|
+
if (timeout <= 0 || !Number.isFinite(timeout)) {
|
|
96
|
+
return new Promise(executor);
|
|
97
|
+
}
|
|
30
98
|
return new Promise((resolve, reject) => {
|
|
31
|
-
const
|
|
99
|
+
const timeoutRejections = () => {
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
101
|
+
const errorObject = err;
|
|
102
|
+
errorObject.message = `${errorObject.message} (${timeout}ms)`;
|
|
103
|
+
reject(err);
|
|
104
|
+
};
|
|
105
|
+
const timer = setTimeout(() => timeoutOptions.reject === false
|
|
106
|
+
? resolve(timeoutOptions.value)
|
|
107
|
+
: timeoutRejections(), timeout);
|
|
32
108
|
executor((value) => {
|
|
33
109
|
clearTimeout(timer);
|
|
34
110
|
resolve(value);
|
|
@@ -38,5 +114,33 @@ async function timeoutPromise(executor, timeoutOptions = {}) {
|
|
|
38
114
|
});
|
|
39
115
|
});
|
|
40
116
|
}
|
|
117
|
+
// Create a promise based on test timeout and the timeout options
|
|
118
|
+
async function timeoutPromise(executor, timeoutOptions = {}) {
|
|
119
|
+
var _a;
|
|
120
|
+
// create the timeout error outside the async task, so its callstack includes
|
|
121
|
+
// the original call site, this makes it easier to debug
|
|
122
|
+
const err = timeoutOptions.reject === false
|
|
123
|
+
? undefined
|
|
124
|
+
: new Error((_a = timeoutOptions.errorMsg) !== null && _a !== void 0 ? _a : "Timed out");
|
|
125
|
+
const executorPromise = getTimeoutPromise(executor, timeoutOptions, err);
|
|
126
|
+
const currentTestTimeout = TestTimeout.getInstance();
|
|
127
|
+
if (currentTestTimeout === undefined) {
|
|
128
|
+
return executorPromise;
|
|
129
|
+
}
|
|
130
|
+
return Promise.race([executorPromise, currentTestTimeout.getPromise()]).catch((e) => {
|
|
131
|
+
var _a;
|
|
132
|
+
if (e === currentTestTimeout) {
|
|
133
|
+
if (timeoutOptions.reject !== false) {
|
|
134
|
+
// If the rejection is because of the timeout then
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
136
|
+
const errorObject = err;
|
|
137
|
+
errorObject.message = `${(_a = timeoutOptions.errorMsg) !== null && _a !== void 0 ? _a : "Test timed out"} (${currentTestTimeout.getTimeout()}ms)`;
|
|
138
|
+
throw errorObject;
|
|
139
|
+
}
|
|
140
|
+
return timeoutOptions.value;
|
|
141
|
+
}
|
|
142
|
+
throw e;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
41
145
|
exports.timeoutPromise = timeoutPromise;
|
|
42
146
|
//# sourceMappingURL=timeoutUtils.js.map
|
package/dist/timeoutUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeoutUtils.js","sourceRoot":"","sources":["../src/timeoutUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIU,QAAA,wBAAwB,GAAG,GAAG,CAAC;AAarC,KAAK,UAAU,YAAY,CAC9B,OAAuB,EACvB,iBAAyD,EAAE;IAE3D,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,cAAc,CAAI,GAAG,EAAE,GAAG,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;AACjF,CAAC;AALD,oCAKC;AAEM,KAAK,UAAU,wBAAwB,CAAC,SAAoB;IAC/D,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;QACtB,OAAO,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;KACpF;AACL,CAAC;AAJD,4DAIC;AAEM,KAAK,UAAU,cAAc,CAChC,QAAgG,EAChG,iBAAyD,EAAE;;IAE3D,MAAM,OAAO,GACT,cAAc,CAAC,UAAU,KAAK,SAAS;WACpC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC;WAC1C,cAAc,CAAC,UAAU,GAAG,CAAC;QAC5B,CAAC,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,gCAAwB,CAAC;IAC/D,6EAA6E;IAC7E,wDAAwD;IACxD,MAAM,GAAG,GAAG,cAAc,CAAC,MAAM,KAAK,KAAK;QACvC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,MAAA,cAAc,CAAC,QAAQ,mCAAI,WAAW,IAAI,OAAO,KAAK,CAAC,CAAC;IAC3E,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,MAAM,KAAK,GAAG,UAAU,CACpB,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EACnF,OAAO,CAAC,CAAC;QAEb,QAAQ,CACJ,CAAC,KAAK,EAAE,EAAE;YACN,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC,EACD,CAAC,MAAM,EAAE,EAAE;YACP,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC;AA7BD,wCA6BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Container } from \"@fluidframework/container-loader\";\n\nexport const defaultTimeoutDurationMs = 250;\n\nexport interface TimeoutWithError {\n durationMs?: number;\n reject?: true;\n errorMsg?: string;\n}\nexport interface TimeoutWithValue<T = void> {\n durationMs?: number;\n reject: false;\n value: T;\n}\n\nexport async function timeoutAwait<T = void>(\n promise: PromiseLike<T>,\n timeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n) {\n return Promise.race([promise, timeoutPromise<T>(() => { }, timeoutOptions)]);\n}\n\nexport async function ensureContainerConnected(container: Container): Promise<void> {\n if (!container.connected) {\n return timeoutPromise((resolve) => container.once(\"connected\", () => resolve()));\n }\n}\n\nexport async function timeoutPromise<T = void>(\n executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void,\n timeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n): Promise<T> {\n const timeout =\n timeoutOptions.durationMs !== undefined\n && Number.isFinite(timeoutOptions.durationMs)\n && timeoutOptions.durationMs > 0\n ? timeoutOptions.durationMs : defaultTimeoutDurationMs;\n // create the timeout error outside the async task, so its callstack includes\n // the original call site, this makes it easier to debug\n const err = timeoutOptions.reject === false\n ? undefined\n : new Error(`${timeoutOptions.errorMsg ?? \"Timed out\"}(${timeout}ms)`);\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(\n () => timeoutOptions.reject === false ? resolve(timeoutOptions.value) : reject(err),\n timeout);\n\n executor(\n (value) => {\n clearTimeout(timer);\n resolve(value);\n },\n (reason) => {\n clearTimeout(timer);\n reject(reason);\n });\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"timeoutUtils.js","sourceRoot":"","sources":["../src/timeoutUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAgE;AAEhE,2CAA2C;AAC9B,QAAA,wBAAwB,GAAG,GAAG,CAAC;AAE5C,kGAAkG;AAClG,yGAAyG;AACzG,0EAA0E;AAE1E,MAAM,UAAU,GAAG,EAAE,CAAC,CAAC,2CAA2C;AAElE,MAAM,WAAW;IAgChB;QA/BQ,YAAO,GAAW,CAAC,CAAC;QAGpB,aAAQ,GAA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A6E;IAC7E,wDAAwD;IACxD,MAAM,GAAG,GACR,cAAc,CAAC,MAAM,KAAK,KAAK;QAC9B,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,IAAI,KAAK,CAAC,MAAA,cAAc,CAAC,QAAQ,mCAAI,WAAW,CAAC,CAAC;IACtD,MAAM,eAAe,GAAG,iBAAiB,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC;IAEzE,MAAM,kBAAkB,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;IACrD,IAAI,kBAAkB,KAAK,SAAS,EAAE;QACrC,OAAO,eAAe,CAAC;KACvB;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,kBAAkB,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;;QACnF,IAAI,CAAC,KAAK,kBAAkB,EAAE;YAC7B,IAAI,cAAc,CAAC,MAAM,KAAK,KAAK,EAAE;gBACpC,kDAAkD;gBAClD,oEAAoE;gBACpE,MAAM,WAAW,GAAG,GAAI,CAAC;gBACzB,WAAW,CAAC,OAAO,GAAG,GACrB,MAAA,cAAc,CAAC,QAAQ,mCAAI,gBAC5B,KAAK,kBAAkB,CAAC,UAAU,EAAE,KAAK,CAAC;gBAC1C,MAAM,WAAW,CAAC;aAClB;YACD,OAAO,cAAc,CAAC,KAAK,CAAC;SAC5B;QACD,MAAM,CAAC,CAAC;IACT,CAAC,CAAe,CAAC;AAClB,CAAC;AAnCD,wCAmCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Deferred } from \"@fluidframework/common-utils\";\n\n// @deprecated this value is no longer used\nexport const defaultTimeoutDurationMs = 250;\n\n// TestTimeout class manage tracking of test timeout. It create a timer when timeout is in effect,\n// and provide a promise that will be reject before the test timeout happen with a `timeBuffer` of 15 ms.\n// Once rejected, a new TestTimeout object will be create for the timeout.\n\nconst timeBuffer = 15; // leave 15 ms leeway for finish processing\n\nclass TestTimeout {\n\tprivate timeout: number = 0;\n\tprivate timer: NodeJS.Timeout | undefined;\n\tprivate readonly deferred: Deferred<void>;\n\tprivate rejected = false;\n\n\tprivate static instance: TestTimeout = new TestTimeout();\n\tpublic static reset(runnable: Mocha.Runnable) {\n\t\tTestTimeout.clear();\n\t\tTestTimeout.instance.resetTimer(runnable);\n\t}\n\n\tpublic static clear() {\n\t\tif (TestTimeout.instance.rejected) {\n\t\t\tTestTimeout.instance = new TestTimeout();\n\t\t} else {\n\t\t\tTestTimeout.instance.clearTimer();\n\t\t}\n\t}\n\n\tpublic static getInstance() {\n\t\treturn TestTimeout.instance;\n\t}\n\n\tpublic async getPromise() {\n\t\treturn this.deferred.promise;\n\t}\n\n\tpublic getTimeout() {\n\t\treturn this.timeout;\n\t}\n\n\tprivate constructor() {\n\t\tthis.deferred = new Deferred();\n\t\t// Ignore rejection for timeout promise if no one is waiting for it.\n\t\tthis.deferred.promise.catch(() => {});\n\t}\n\n\tprivate resetTimer(runnable: Mocha.Runnable) {\n\t\tassert(!this.timer, \"clearTimer should have been called before reset\");\n\t\tassert(!this.deferred.isCompleted, \"can't reset a completed TestTimeout\");\n\n\t\t// Check the test timeout setting\n\t\tconst timeout = runnable.timeout();\n\t\tif (!(Number.isFinite(timeout) && timeout > 0)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// subtract a buffer\n\t\tthis.timeout = Math.max(timeout - timeBuffer, 1);\n\n\t\t// Set up timer to reject near the test timeout.\n\t\tthis.timer = setTimeout(() => {\n\t\t\tthis.deferred.reject(this);\n\t\t\tthis.rejected = true;\n\t\t}, this.timeout);\n\t}\n\tprivate clearTimer() {\n\t\tif (this.timer) {\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = undefined;\n\t\t}\n\t}\n}\n\n// only register if we are running with mocha-test-setup loaded\nif (globalThis.getMochaModule !== undefined) {\n\t// patching resetTimeout and clearTimeout on the runnable object\n\t// so we can track when test timeout are enforced\n\tconst mochaModule = globalThis.getMochaModule() as typeof Mocha;\n\tconst runnablePrototype = mochaModule.Runnable.prototype;\n\t// eslint-disable-next-line @typescript-eslint/unbound-method\n\tconst oldResetTimeoutFunc = runnablePrototype.resetTimeout;\n\trunnablePrototype.resetTimeout = function (this: Mocha.Runnable) {\n\t\toldResetTimeoutFunc.call(this);\n\t\tTestTimeout.reset(this);\n\t};\n\t// eslint-disable-next-line @typescript-eslint/unbound-method\n\tconst oldClearTimeoutFunc = runnablePrototype.clearTimeout;\n\trunnablePrototype.clearTimeout = function (this: Mocha.Runnable) {\n\t\tTestTimeout.clear();\n\t\toldClearTimeoutFunc.call(this);\n\t};\n}\n\nexport interface TimeoutWithError {\n\t/**\n\t * Timeout duration in milliseconds, if it is great than 0 and not Infinity\n\t * If it is undefined, then it will use test timeout if we are in side the test function\n\t * Otherwise, there is no timeout\n\t */\n\tdurationMs?: number;\n\treject?: true;\n\terrorMsg?: string;\n}\nexport interface TimeoutWithValue<T = void> {\n\t/**\n\t * Timeout duration in milliseconds, if it is great than 0 and not Infinity\n\t * If it is undefined, then it will use test timeout if we are in side the test function\n\t * Otherwise, there is no timeout\n\t */\n\tdurationMs?: number;\n\treject: false;\n\tvalue: T;\n}\n\nexport type PromiseExecutor<T = void> = (\n\tresolve: (value: T | PromiseLike<T>) => void,\n\treject: (reason?: any) => void,\n) => void;\n\nexport async function timeoutAwait<T = void>(\n\tpromise: PromiseLike<T>,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n) {\n\treturn Promise.race([promise, timeoutPromise<T>(() => {}, timeoutOptions)]);\n}\n\n// Create a promise based on the timeout options\nasync function getTimeoutPromise<T = void>(\n\texecutor: (\n\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\treject: (reason?: any) => void,\n\t) => void,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T>,\n\terr: Error | undefined,\n) {\n\tconst timeout = timeoutOptions.durationMs ?? 0;\n\tif (timeout <= 0 || !Number.isFinite(timeout)) {\n\t\treturn new Promise(executor);\n\t}\n\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst timeoutRejections = () => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst errorObject = err!;\n\t\t\terrorObject.message = `${errorObject.message} (${timeout}ms)`;\n\t\t\treject(err);\n\t\t};\n\t\tconst timer = setTimeout(\n\t\t\t() =>\n\t\t\t\ttimeoutOptions.reject === false\n\t\t\t\t\t? resolve(timeoutOptions.value)\n\t\t\t\t\t: timeoutRejections(),\n\t\t\ttimeout,\n\t\t);\n\n\t\texecutor(\n\t\t\t(value) => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve(value);\n\t\t\t},\n\t\t\t(reason) => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\treject(reason);\n\t\t\t},\n\t\t);\n\t});\n}\n\n// Create a promise based on test timeout and the timeout options\nexport async function timeoutPromise<T = void>(\n\texecutor: (\n\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\treject: (reason?: any) => void,\n\t) => void,\n\ttimeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n): Promise<T> {\n\t// create the timeout error outside the async task, so its callstack includes\n\t// the original call site, this makes it easier to debug\n\tconst err =\n\t\ttimeoutOptions.reject === false\n\t\t\t? undefined\n\t\t\t: new Error(timeoutOptions.errorMsg ?? \"Timed out\");\n\tconst executorPromise = getTimeoutPromise(executor, timeoutOptions, err);\n\n\tconst currentTestTimeout = TestTimeout.getInstance();\n\tif (currentTestTimeout === undefined) {\n\t\treturn executorPromise;\n\t}\n\n\treturn Promise.race([executorPromise, currentTestTimeout.getPromise()]).catch((e) => {\n\t\tif (e === currentTestTimeout) {\n\t\t\tif (timeoutOptions.reject !== false) {\n\t\t\t\t// If the rejection is because of the timeout then\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst errorObject = err!;\n\t\t\t\terrorObject.message = `${\n\t\t\t\t\ttimeoutOptions.errorMsg ?? \"Test timed out\"\n\t\t\t\t} (${currentTestTimeout.getTimeout()}ms)`;\n\t\t\t\tthrow errorObject;\n\t\t\t}\n\t\t\treturn timeoutOptions.value;\n\t\t}\n\t\tthrow e;\n\t}) as Promise<T>;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/test-utils",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.4.1.0.148229",
|
|
4
4
|
"description": "Utilities for Fluid tests",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -14,28 +14,6 @@
|
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"module": "lib/index.js",
|
|
16
16
|
"types": "dist/index.d.ts",
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
|
|
19
|
-
"build:compile": "npm run tsc && npm run typetests:gen && npm run build:test",
|
|
20
|
-
"build:compile:min": "npm run build:compile",
|
|
21
|
-
"build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
|
|
22
|
-
"build:full": "npm run build",
|
|
23
|
-
"build:full:compile": "npm run build:compile",
|
|
24
|
-
"build:genver": "gen-version",
|
|
25
|
-
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
26
|
-
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
|
|
27
|
-
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
28
|
-
"eslint": "eslint --format stylish src",
|
|
29
|
-
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
30
|
-
"format": "npm run prettier:fix",
|
|
31
|
-
"lint": "npm run eslint",
|
|
32
|
-
"lint:fix": "npm run eslint:fix",
|
|
33
|
-
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
34
|
-
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
35
|
-
"tsc": "tsc",
|
|
36
|
-
"typetests:gen": "flub generate typetests --generate --dir .",
|
|
37
|
-
"typetests:prepare": "flub generate typetests --prepare --dir . --pin"
|
|
38
|
-
},
|
|
39
17
|
"nyc": {
|
|
40
18
|
"all": true,
|
|
41
19
|
"cache-dir": "nyc/.cache",
|
|
@@ -57,59 +35,88 @@
|
|
|
57
35
|
"temp-directory": "nyc/.nyc_output"
|
|
58
36
|
},
|
|
59
37
|
"dependencies": {
|
|
60
|
-
"@fluidframework/aqueduct": "
|
|
38
|
+
"@fluidframework/aqueduct": "2.0.0-dev.4.1.0.148229",
|
|
61
39
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
62
|
-
"@fluidframework/common-utils": "^1.
|
|
63
|
-
"@fluidframework/container-definitions": "
|
|
64
|
-
"@fluidframework/container-loader": "
|
|
65
|
-
"@fluidframework/container-runtime": "
|
|
66
|
-
"@fluidframework/container-runtime-definitions": "
|
|
67
|
-
"@fluidframework/core-interfaces": "
|
|
68
|
-
"@fluidframework/datastore": "
|
|
69
|
-
"@fluidframework/datastore-definitions": "
|
|
70
|
-
"@fluidframework/driver-definitions": "
|
|
71
|
-
"@fluidframework/driver-utils": "
|
|
72
|
-
"@fluidframework/local-driver": "
|
|
73
|
-
"@fluidframework/map": "
|
|
40
|
+
"@fluidframework/common-utils": "^1.1.1",
|
|
41
|
+
"@fluidframework/container-definitions": "2.0.0-dev.4.1.0.148229",
|
|
42
|
+
"@fluidframework/container-loader": "2.0.0-dev.4.1.0.148229",
|
|
43
|
+
"@fluidframework/container-runtime": "2.0.0-dev.4.1.0.148229",
|
|
44
|
+
"@fluidframework/container-runtime-definitions": "2.0.0-dev.4.1.0.148229",
|
|
45
|
+
"@fluidframework/core-interfaces": "2.0.0-dev.4.1.0.148229",
|
|
46
|
+
"@fluidframework/datastore": "2.0.0-dev.4.1.0.148229",
|
|
47
|
+
"@fluidframework/datastore-definitions": "2.0.0-dev.4.1.0.148229",
|
|
48
|
+
"@fluidframework/driver-definitions": "2.0.0-dev.4.1.0.148229",
|
|
49
|
+
"@fluidframework/driver-utils": "2.0.0-dev.4.1.0.148229",
|
|
50
|
+
"@fluidframework/local-driver": "2.0.0-dev.4.1.0.148229",
|
|
51
|
+
"@fluidframework/map": "2.0.0-dev.4.1.0.148229",
|
|
74
52
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
75
|
-
"@fluidframework/request-handler": "
|
|
76
|
-
"@fluidframework/routerlicious-driver": "
|
|
77
|
-
"@fluidframework/runtime-definitions": "
|
|
78
|
-
"@fluidframework/runtime-utils": "
|
|
79
|
-
"@fluidframework/telemetry-utils": "
|
|
80
|
-
"@fluidframework/test-driver-definitions": "
|
|
81
|
-
"@fluidframework/test-runtime-utils": "
|
|
53
|
+
"@fluidframework/request-handler": "2.0.0-dev.4.1.0.148229",
|
|
54
|
+
"@fluidframework/routerlicious-driver": "2.0.0-dev.4.1.0.148229",
|
|
55
|
+
"@fluidframework/runtime-definitions": "2.0.0-dev.4.1.0.148229",
|
|
56
|
+
"@fluidframework/runtime-utils": "2.0.0-dev.4.1.0.148229",
|
|
57
|
+
"@fluidframework/telemetry-utils": "2.0.0-dev.4.1.0.148229",
|
|
58
|
+
"@fluidframework/test-driver-definitions": "2.0.0-dev.4.1.0.148229",
|
|
59
|
+
"@fluidframework/test-runtime-utils": "2.0.0-dev.4.1.0.148229",
|
|
82
60
|
"best-random": "^1.0.0",
|
|
83
61
|
"debug": "^4.1.1",
|
|
84
62
|
"uuid": "^8.3.1"
|
|
85
63
|
},
|
|
86
64
|
"devDependencies": {
|
|
87
|
-
"@fluid-tools/build-cli": "^0.
|
|
65
|
+
"@fluid-tools/build-cli": "^0.13.1",
|
|
88
66
|
"@fluidframework/build-common": "^1.1.0",
|
|
89
|
-
"@fluidframework/build-tools": "^0.
|
|
90
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
91
|
-
"@fluidframework/test-
|
|
92
|
-
"@
|
|
93
|
-
"@
|
|
67
|
+
"@fluidframework/build-tools": "^0.13.1",
|
|
68
|
+
"@fluidframework/eslint-config-fluid": "^2.0.0",
|
|
69
|
+
"@fluidframework/mocha-test-setup": "2.0.0-dev.4.1.0.148229",
|
|
70
|
+
"@fluidframework/test-utils-previous": "npm:@fluidframework/test-utils@2.0.0-internal.4.0.0",
|
|
71
|
+
"@microsoft/api-extractor": "^7.34.4",
|
|
72
|
+
"@types/debug": "^4.1.5",
|
|
94
73
|
"@types/diff": "^3.5.1",
|
|
95
74
|
"@types/mocha": "^9.1.1",
|
|
96
|
-
"@types/node": "^14.18.
|
|
75
|
+
"@types/node": "^14.18.38",
|
|
97
76
|
"@types/random-js": "^1.0.31",
|
|
98
|
-
"
|
|
77
|
+
"@types/uuid": "^8.3.0",
|
|
78
|
+
"concurrently": "^7.6.0",
|
|
99
79
|
"copyfiles": "^2.4.1",
|
|
80
|
+
"cross-env": "^7.0.3",
|
|
100
81
|
"diff": "^3.5.0",
|
|
101
82
|
"eslint": "~8.6.0",
|
|
102
|
-
"mocha": "^10.
|
|
103
|
-
"
|
|
83
|
+
"mocha": "^10.2.0",
|
|
84
|
+
"mocha-json-output-reporter": "^2.0.1",
|
|
85
|
+
"mocha-multi-reporters": "^1.5.1",
|
|
86
|
+
"moment": "^2.21.0",
|
|
87
|
+
"nyc": "^15.1.0",
|
|
104
88
|
"prettier": "~2.6.2",
|
|
105
89
|
"random-js": "^1.0.8",
|
|
106
|
-
"rimraf": "^
|
|
90
|
+
"rimraf": "^4.4.0",
|
|
107
91
|
"typescript": "~4.5.5"
|
|
108
92
|
},
|
|
109
93
|
"typeValidation": {
|
|
110
|
-
"version": "2.0.0-internal.2.3.0",
|
|
111
|
-
"baselineRange": ">=2.0.0-internal.2.2.0 <2.0.0-internal.2.3.0",
|
|
112
|
-
"baselineVersion": "2.0.0-internal.2.2.0",
|
|
113
94
|
"broken": {}
|
|
95
|
+
},
|
|
96
|
+
"scripts": {
|
|
97
|
+
"build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
|
|
98
|
+
"build:compile": "npm run tsc && npm run typetests:gen && npm run build:test",
|
|
99
|
+
"build:compile:min": "npm run build:compile",
|
|
100
|
+
"build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
|
|
101
|
+
"build:full": "npm run build",
|
|
102
|
+
"build:full:compile": "npm run build:compile",
|
|
103
|
+
"build:genver": "gen-version",
|
|
104
|
+
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
105
|
+
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
|
|
106
|
+
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
107
|
+
"eslint": "eslint --format stylish src",
|
|
108
|
+
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
109
|
+
"format": "npm run prettier:fix",
|
|
110
|
+
"lint": "npm run prettier && npm run eslint",
|
|
111
|
+
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
|
|
112
|
+
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
113
|
+
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
114
|
+
"test": "npm run test:mocha",
|
|
115
|
+
"test:mocha": "mocha --unhandled-rejections=strict --recursive dist/test/*.spec.js --exit --project src/test/tsconfig.json -r node_modules/@fluidframework/mocha-test-setup",
|
|
116
|
+
"test:mocha:multireport": "cross-env FLUID_TEST_MULTIREPORT=1 npm run test:mocha",
|
|
117
|
+
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
118
|
+
"tsc": "tsc",
|
|
119
|
+
"typetests:gen": "fluid-type-test-generator",
|
|
120
|
+
"typetests:prepare": "flub generate typetests --prepare --dir . --pin"
|
|
114
121
|
}
|
|
115
|
-
}
|
|
122
|
+
}
|
package/prettier.config.cjs
CHANGED
package/src/DriverWrappers.ts
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
IDocumentService,
|
|
9
|
+
IDocumentServiceFactory,
|
|
10
|
+
IDocumentStorageService,
|
|
11
|
+
IResolvedUrl,
|
|
12
|
+
ISummaryContext,
|
|
13
13
|
} from "@fluidframework/driver-definitions";
|
|
14
14
|
import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
15
15
|
|
|
@@ -19,18 +19,18 @@ import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
|
19
19
|
* callback before it is uploaded to the server.
|
|
20
20
|
*/
|
|
21
21
|
export function wrapDocumentStorageService(
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
innerDocStorageService: IDocumentStorageService,
|
|
23
|
+
uploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext,
|
|
24
24
|
) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
const outerDocStorageService = Object.create(innerDocStorageService) as IDocumentStorageService;
|
|
26
|
+
outerDocStorageService.uploadSummaryWithContext = async (
|
|
27
|
+
summary: ISummaryTree,
|
|
28
|
+
context: ISummaryContext,
|
|
29
|
+
): Promise<string> => {
|
|
30
|
+
const newContext = uploadSummaryCb(summary, context);
|
|
31
|
+
return innerDocStorageService.uploadSummaryWithContext(summary, newContext);
|
|
32
|
+
};
|
|
33
|
+
return outerDocStorageService;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -41,15 +41,15 @@ export function wrapDocumentStorageService(
|
|
|
41
41
|
* to pass in the `uploadSummaryCb`.
|
|
42
42
|
*/
|
|
43
43
|
export function wrapDocumentService(
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
innerDocService: IDocumentService,
|
|
45
|
+
uploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext,
|
|
46
46
|
) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
const outerDocService = Object.create(innerDocService) as IDocumentService;
|
|
48
|
+
outerDocService.connectToStorage = async (): Promise<IDocumentStorageService> => {
|
|
49
|
+
const storageService = await innerDocService.connectToStorage();
|
|
50
|
+
return wrapDocumentStorageService(storageService, uploadSummaryCb);
|
|
51
|
+
};
|
|
52
|
+
return outerDocService;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
@@ -60,18 +60,21 @@ export function wrapDocumentService(
|
|
|
60
60
|
* pass in the `uploadSummaryCb`.
|
|
61
61
|
*/
|
|
62
62
|
export function wrapDocumentServiceFactory(
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
innerDocServiceFactory: IDocumentServiceFactory,
|
|
64
|
+
uploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext,
|
|
65
65
|
) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
const outerDocServiceFactory = Object.create(innerDocServiceFactory) as IDocumentServiceFactory;
|
|
67
|
+
outerDocServiceFactory.createDocumentService = async (
|
|
68
|
+
resolvedUrl: IResolvedUrl,
|
|
69
|
+
logger?: ITelemetryBaseLogger,
|
|
70
|
+
clientIsSummarizer?: boolean,
|
|
71
|
+
): Promise<IDocumentService> => {
|
|
72
|
+
const documentService = await innerDocServiceFactory.createDocumentService(
|
|
73
|
+
resolvedUrl,
|
|
74
|
+
logger,
|
|
75
|
+
clientIsSummarizer,
|
|
76
|
+
);
|
|
77
|
+
return wrapDocumentService(documentService, uploadSummaryCb);
|
|
78
|
+
};
|
|
79
|
+
return outerDocServiceFactory;
|
|
77
80
|
}
|
package/src/TestConfigs.ts
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
import { ConfigTypes, IConfigProviderBase } from "@fluidframework/telemetry-utils";
|
|
7
7
|
|
|
8
|
-
export const mockConfigProvider = (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
8
|
+
export const mockConfigProvider = (
|
|
9
|
+
settings: Record<string, ConfigTypes> = {},
|
|
10
|
+
): IConfigProviderBase => {
|
|
11
|
+
return {
|
|
12
|
+
getRawConfig: (name: string): ConfigTypes => settings[name],
|
|
13
|
+
};
|
|
14
|
+
};
|