@fluid-internal/mocha-test-setup 2.117.0 → 3.0.0
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/CHANGELOG.md +1 -1
- package/README.md +13 -15
- package/{api-extractor.json → api-extractor/api-extractor-model.json} +1 -1
- package/api-extractor/api-extractor-report.json +5 -0
- package/api-report/mocha-test-setup.alpha.api.md +0 -2
- package/api-report/mocha-test-setup.beta.api.md +0 -2
- package/api-report/mocha-test-setup.public.api.md +0 -2
- package/lib/mochaHooks.d.ts +0 -1
- package/lib/mochaHooks.d.ts.map +1 -1
- package/lib/mochaHooks.js +7 -4
- package/lib/mochaHooks.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +14 -11
- package/src/mochaHooks.ts +31 -21
- package/src/packageVersion.ts +1 -1
- package/tsconfig.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
<!-- prettier-ignore-start -->
|
|
6
6
|
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
|
7
7
|
|
|
8
|
-
**IMPORTANT:
|
|
9
|
-
**
|
|
8
|
+
**IMPORTANT: Fluid Framework uses this package as an implementation detail.**
|
|
9
|
+
**Do not use it as a public dependency.**
|
|
10
|
+
**We do not guarantee the stability of this package or its APIs.**
|
|
10
11
|
|
|
11
12
|
<!-- prettier-ignore-end -->
|
|
12
13
|
|
|
@@ -193,17 +194,18 @@ by requiring that the path be provided through that environment variable.
|
|
|
193
194
|
|
|
194
195
|
## Contribution Guidelines
|
|
195
196
|
|
|
196
|
-
|
|
197
|
+
You can [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid Framework in these ways:
|
|
197
198
|
|
|
198
|
-
-
|
|
199
|
-
- [Submit
|
|
200
|
-
- Review
|
|
199
|
+
- Answer questions in [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
|
|
200
|
+
- [Submit bug reports](https://github.com/microsoft/FluidFramework/issues) and help verify fixes.
|
|
201
|
+
- Review [source code changes](https://github.com/microsoft/FluidFramework/pulls).
|
|
201
202
|
- [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
|
|
202
203
|
|
|
203
|
-
|
|
204
|
+
For detailed instructions, read the [repo documentation](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Home.md).
|
|
204
205
|
|
|
205
|
-
This project
|
|
206
|
-
For more information
|
|
206
|
+
This project follows the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
207
|
+
For more information, read the [Code of Conduct frequently asked questions](https://opensource.microsoft.com/codeofconduct/faq/).
|
|
208
|
+
For questions or comments, contact [opencode@microsoft.com](mailto:opencode@microsoft.com).
|
|
207
209
|
|
|
208
210
|
This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
|
|
209
211
|
Use of these trademarks or logos must follow Microsoft’s [Trademark & Brand Guidelines](https://www.microsoft.com/trademarks).
|
|
@@ -211,13 +213,9 @@ Use of Microsoft trademarks or logos in modified versions of this project must n
|
|
|
211
213
|
|
|
212
214
|
## Help
|
|
213
215
|
|
|
214
|
-
|
|
215
|
-
Check out [fluidframework.com](https://fluidframework.com/docs/).
|
|
216
|
+
Read the [Fluid Framework documentation](https://fluidframework.com/docs/) for information about Fluid Framework concepts and APIs.
|
|
216
217
|
|
|
217
|
-
|
|
218
|
-
Please [file an issue](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Contributing/Submitting-Bugs-and-Feature-Requests.md).
|
|
219
|
-
|
|
220
|
-
Thank you!
|
|
218
|
+
To request information that the documentation does not contain, [create an issue](https://github.com/microsoft/FluidFramework/blob/main/docs/content/Contributing/Submitting-Bugs-and-Feature-Requests.md).
|
|
221
219
|
|
|
222
220
|
## Trademark
|
|
223
221
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
-
"extends": "
|
|
3
|
+
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-model.esm.json"
|
|
4
4
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-report-base.esm.json",
|
|
4
|
+
"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts"
|
|
5
|
+
}
|
package/lib/mochaHooks.d.ts
CHANGED
package/lib/mochaHooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mochaHooks.d.ts","sourceRoot":"","sources":["../src/mochaHooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;;
|
|
1
|
+
{"version":3,"file":"mochaHooks.d.ts","sourceRoot":"","sources":["../src/mochaHooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8FH;;GAEG;AACH,eAAO,MAAM,UAAU;;qBAkCL,KAAK,CAAC,OAAO;oBA2Bd,KAAK,CAAC,OAAO;mBAwBR,KAAK,CAAC,OAAO;CAMlC,CAAC"}
|
package/lib/mochaHooks.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
import { LogLevel } from "@fluidframework/core-interfaces";
|
|
5
6
|
import * as mochaModule from "mocha";
|
|
6
7
|
import { pkgName } from "./packageVersion.js";
|
|
7
8
|
// This will enable capturing the full stack for errors.
|
|
@@ -20,7 +21,9 @@ const _global = global;
|
|
|
20
21
|
* run (odsp, r11s, etc) and the name of the current test (while in the context of a particular test running).
|
|
21
22
|
*/
|
|
22
23
|
class FluidTestRunLogger {
|
|
23
|
-
|
|
24
|
+
parentLogger;
|
|
25
|
+
currentTestName;
|
|
26
|
+
send(event, logLevel) {
|
|
24
27
|
// TODO: Remove when issue #7061 is resolved.
|
|
25
28
|
// Don't log this event as we generate too much.
|
|
26
29
|
if (event.eventName === "fluid:telemetry:RouterliciousDriver:readBlob_end") {
|
|
@@ -36,7 +39,7 @@ class FluidTestRunLogger {
|
|
|
36
39
|
// But prefer a value set through FLUID_LOGGER_PROPS if it exists.
|
|
37
40
|
hostName: envLoggerProps?.hostName ?? pkgName,
|
|
38
41
|
testEnvProps: JSON.stringify(envLoggerProps),
|
|
39
|
-
});
|
|
42
|
+
}, logLevel);
|
|
40
43
|
}
|
|
41
44
|
async flush() {
|
|
42
45
|
return this.parentLogger.flush();
|
|
@@ -127,7 +130,7 @@ export const mochaHooks = {
|
|
|
127
130
|
testLogger.send({
|
|
128
131
|
category: "generic",
|
|
129
132
|
eventName: "fluid:telemetry:Test_start",
|
|
130
|
-
});
|
|
133
|
+
}, LogLevel.essential);
|
|
131
134
|
},
|
|
132
135
|
afterEach() {
|
|
133
136
|
ensureTestRunLoggerIsInitialized(testLogger);
|
|
@@ -139,7 +142,7 @@ export const mochaHooks = {
|
|
|
139
142
|
timedOut: this.currentTest?.timedOut,
|
|
140
143
|
error: this.currentTest?.err?.message,
|
|
141
144
|
stack: this.currentTest?.err?.stack,
|
|
142
|
-
});
|
|
145
|
+
}, LogLevel.essential);
|
|
143
146
|
// Restore console output now that the current test is done running.
|
|
144
147
|
console.log = log;
|
|
145
148
|
console.error = error;
|
package/lib/mochaHooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mochaHooks.js","sourceRoot":"","sources":["../src/mochaHooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,WAAW,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAq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AI,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO;YACrC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK;SACnC,CAAC,CAAC;QAEH,oEAAoE;QACpE,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC;QAClB,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACtB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QAEpB,kHAAkH;QAClH,gHAAgH;QAChH,UAAU,CAAC,gBAAgB,EAAE,CAAC;IAC/B,CAAC;IACD,KAAK,CAAC,QAAQ;QACb,2CAA2C;QAC3C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnB,gGAAgG;QAChG,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACD,CAAC;AAEF,UAAU,CAAC,cAAc,GAAG,GAAG,EAAE;IAChC,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC;AAEF,SAAS,gCAAgC,CACxC,YAA4C;IAE5C,IAAI,YAAY,YAAY,kBAAkB,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;AACvD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBufferedLogger } from \"@fluid-internal/test-driver-definitions\";\nimport type { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport * as mochaModule from \"mocha\";\n\nimport { pkgName } from \"./packageVersion.js\";\n\n// This will enable capturing the full stack for errors.\n// Since this package is only used when we run tests, capturing the full stack is worth it.\n// In non-test environments we need to be more cautious as this will incur a perf impact when errors are\n// thrown and will take more storage in any logging sink.\n// https://v8.dev/docs/stack-trace-api\nError.stackTraceLimit = Number.POSITIVE_INFINITY;\n\nconst testVariant = process.env.FLUID_TEST_VARIANT;\nconst envLoggerProps =\n\tprocess.env.FLUID_LOGGER_PROPS != null\n\t\t? JSON.parse(process.env.FLUID_LOGGER_PROPS)\n\t\t: undefined;\n\nconst _global: any = global;\n\n/**\n * A logger that adds context about the current test run to all events logged through it, like the test variant being\n * run (odsp, r11s, etc) and the name of the current test (while in the context of a particular test running).\n */\nclass FluidTestRunLogger implements ITelemetryBufferedLogger {\n\tprivate currentTestName: string | undefined;\n\n\tsend(event: ITelemetryBaseEvent): void {\n\t\t// TODO: Remove when issue #7061 is resolved.\n\t\t// Don't log this event as we generate too much.\n\t\tif (event.eventName === \"fluid:telemetry:RouterliciousDriver:readBlob_end\") {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.currentTestName !== undefined) {\n\t\t\tevent.testName = this.currentTestName;\n\t\t}\n\t\tevent.testVariant = testVariant;\n\t\tthis.parentLogger.send({\n\t\t\t...event,\n\t\t\t// Setting hostname to pkgName is the behavior we had for a long time, so keeping it just in case.\n\t\t\t// But prefer a value set through FLUID_LOGGER_PROPS if it exists.\n\t\t\thostName: envLoggerProps?.hostName ?? pkgName,\n\t\t\ttestEnvProps: JSON.stringify(envLoggerProps),\n\t\t});\n\t}\n\tasync flush(): Promise<void> {\n\t\treturn this.parentLogger.flush();\n\t}\n\tconstructor(private readonly parentLogger: ITelemetryBufferedLogger) {}\n\n\t/**\n\t * Sets the test that is currently running.\n\t * The test name will be included in all events logged through the logger until {@link clearCurrentTest} is called.\n\t * @param testName - The name of the test that is currently running.\n\t */\n\tpublic setCurrentTest(testName: string): void {\n\t\tthis.currentTestName = testName;\n\t}\n\n\t/**\n\t * Clears the test that is currently running.\n\t * Must be called after a given test has completed so that events logged outside the context of a test\n\t * don't include the name of the last test that ran.\n\t */\n\tpublic clearCurrentTest(): void {\n\t\tthis.currentTestName = undefined;\n\t}\n}\nconst nullLogger: ITelemetryBufferedLogger = {\n\tsend: (): void => {},\n\tflush: async (): Promise<void> => {},\n};\n\n// Keep references to the original console functions so we can restore them after each test.\nconst log = console.log;\nconst error = console.log;\nconst warn = console.warn;\n\nlet testLogger: FluidTestRunLogger;\n\n/**\n * The amount of time to wait after logging an event before flushing the logger.\n * This amount was decided after doing tests with different values. See AB#44378 for details.\n */\nconst AFTER_FLUSH_DELAY_MS = 1250;\n\n/**\n * @internal\n */\nexport const mochaHooks = {\n\tasync beforeAll() {\n\t\t// Code in our tests will call the global `getTestLogger` function to get a logger to use.\n\n\t\t// First we call the version of that function that was (potentially) injected dynamicaly to get the logger that it\n\t\t// provides and wrap it with a more intelligent logger which adds test-run-related context to all events logged\n\t\t// through it. See the documentation on `FluidTestRunLogger` for details.\n\t\tlet originalLogger: ITelemetryBufferedLogger;\n\n\t\tif (process.env.FLUID_TEST_LOGGER_PKG_SPECIFIER === undefined) {\n\t\t\toriginalLogger = nullLogger;\n\t\t} else {\n\t\t\tconst { createTestLogger } = await import(process.env.FLUID_TEST_LOGGER_PKG_SPECIFIER);\n\t\t\tif (typeof createTestLogger !== \"function\") {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Expected package '${process.env.FLUID_TEST_LOGGER_PKG_SPECIFIER}' to export a function, but got an object of type '${typeof createTestLogger}' instead`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\toriginalLogger = createTestLogger({\n\t\t\t\t\tafterFlushDelayMs: AFTER_FLUSH_DELAY_MS,\n\t\t\t\t\tthrottleLogging: false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\ttestLogger = new FluidTestRunLogger(originalLogger);\n\n\t\t// Then we redefine `getTestLogger` so it returns the wrapper logger.\n\t\t// NOTE: if we have other global mocha hooks defined somewhere, they include a `beforeEach` hook, and the module in\n\t\t// which they are defined gets loaded before this one, then if that `beforeEach` hook calls `getTestLogger` the logger\n\t\t// it will get will still have a lot of the test-run-related context, but not the name of the current test, because\n\t\t// it will run before the `beforeEach` hook in this file which sets that.\n\t\t_global.getTestLogger = () => testLogger;\n\t},\n\tbeforeEach(this: Mocha.Context) {\n\t\t// If not in verbose mode, suppress console output while the current test runs.\n\t\tif (process.env.FLUID_TEST_VERBOSE === undefined) {\n\t\t\tconsole.log = () => {};\n\t\t\tconsole.error = () => {};\n\t\t\tconsole.warn = () => {};\n\t\t}\n\n\t\tensureTestRunLoggerIsInitialized(testLogger);\n\n\t\tlet testTitle = \"\";\n\t\tif (this.currentTest !== undefined) {\n\t\t\tif (testVariant !== undefined) {\n\t\t\t\tthis.currentTest.title = `[${testVariant}] ${this.currentTest.title}`;\n\t\t\t}\n\t\t\ttestTitle = this.currentTest.fullTitle();\n\t\t}\n\t\ttestLogger.setCurrentTest(testTitle);\n\n\t\ttestLogger.send({\n\t\t\tcategory: \"generic\",\n\t\t\teventName: \"fluid:telemetry:Test_start\",\n\t\t});\n\t},\n\tafterEach(this: Mocha.Context) {\n\t\tensureTestRunLoggerIsInitialized(testLogger);\n\t\ttestLogger.send({\n\t\t\tcategory: \"generic\",\n\t\t\teventName: \"fluid:telemetry:Test_end\",\n\t\t\tstate: this.currentTest?.state,\n\t\t\tduration: this.currentTest?.duration,\n\t\t\ttimedOut: this.currentTest?.timedOut,\n\t\t\terror: this.currentTest?.err?.message,\n\t\t\tstack: this.currentTest?.err?.stack,\n\t\t});\n\n\t\t// Restore console output now that the current test is done running.\n\t\tconsole.log = log;\n\t\tconsole.error = error;\n\t\tconsole.warn = warn;\n\n\t\t// Clear the current test from the logger. Important so if anything calls `getTestLogger` outside the context of a\n\t\t// test (e.g. during a `before` or `after` hook), it doesn't log events with the name of the last test that ran.\n\t\ttestLogger.clearCurrentTest();\n\t},\n\tasync afterAll(this: Mocha.Context) {\n\t\t// Allow 5 seconds for the logger to flush.\n\t\tthis.timeout(5000);\n\t\t// After all tests ran, flush the logger to ensure all events are sent before the process exits.\n\t\tawait testLogger.flush();\n\t},\n};\n\nglobalThis.getMochaModule = () => {\n\treturn mochaModule;\n};\n\nfunction ensureTestRunLoggerIsInitialized(\n\tloggerToTest: FluidTestRunLogger | undefined,\n): loggerToTest is FluidTestRunLogger {\n\tif (loggerToTest instanceof FluidTestRunLogger) {\n\t\treturn true;\n\t}\n\tthrow new Error(\"Test run logger is not initialized\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mochaHooks.js","sourceRoot":"","sources":["../src/mochaHooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,KAAK,WAAW,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,wDAAwD;AACxD,2FAA2F;AAC3F,wGAAwG;AACxG,yDAAyD;AACzD,sCAAsC;AACtC,KAAK,CAAC,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAEjD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;AACnD,MAAM,cAAc,GACnB,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,IAAI;IACrC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAC5C,CAAC,CAAC,SAAS,CAAC;AAEd,MAAM,OAAO,GAAQ,MAAM,CAAC;AAE5B;;;GAGG;AACH,MAAM,kBAAkB;IA4BM;IA3BrB,eAAe,CAAqB;IAE5C,IAAI,CAAC,KAA0B,EAAE,QAAkB;QAClD,6CAA6C;QAC7C,gDAAgD;QAChD,IAAI,KAAK,CAAC,SAAS,KAAK,kDAAkD,EAAE,CAAC;YAC5E,OAAO;QACR,CAAC;QAED,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YACxC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC;QACvC,CAAC;QACD,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,YAAY,CAAC,IAAI,CACrB;YACC,GAAG,KAAK;YACR,kGAAkG;YAClG,kEAAkE;YAClE,QAAQ,EAAE,cAAc,EAAE,QAAQ,IAAI,OAAO;YAC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AE,4BAA4B;SACvC,EACD,QAAQ,CAAC,SAAS,CAClB,CAAC;IACH,CAAC;IACD,SAAS;QACR,gCAAgC,CAAC,UAAU,CAAC,CAAC;QAC7C,UAAU,CAAC,IAAI,CACd;YACC,QAAQ,EAAE,SAAS;YACnB,SAAS,EAAE,0BAA0B;YACrC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK;YAC9B,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ;YACpC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ;YACpC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO;YACrC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK;SACnC,EACD,QAAQ,CAAC,SAAS,CAClB,CAAC;QAEF,oEAAoE;QACpE,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC;QAClB,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACtB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QAEpB,kHAAkH;QAClH,gHAAgH;QAChH,UAAU,CAAC,gBAAgB,EAAE,CAAC;IAC/B,CAAC;IACD,KAAK,CAAC,QAAQ;QACb,2CAA2C;QAC3C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnB,gGAAgG;QAChG,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACD,CAAC;AAEF,UAAU,CAAC,cAAc,GAAG,GAAG,EAAE;IAChC,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC;AAEF,SAAS,gCAAgC,CACxC,YAA4C;IAE5C,IAAI,YAAY,YAAY,kBAAkB,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;AACvD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBufferedLogger } from \"@fluid-internal/test-driver-definitions\";\nimport type { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport { LogLevel } from \"@fluidframework/core-interfaces\";\nimport * as mochaModule from \"mocha\";\n\nimport { pkgName } from \"./packageVersion.js\";\n\n// This will enable capturing the full stack for errors.\n// Since this package is only used when we run tests, capturing the full stack is worth it.\n// In non-test environments we need to be more cautious as this will incur a perf impact when errors are\n// thrown and will take more storage in any logging sink.\n// https://v8.dev/docs/stack-trace-api\nError.stackTraceLimit = Number.POSITIVE_INFINITY;\n\nconst testVariant = process.env.FLUID_TEST_VARIANT;\nconst envLoggerProps =\n\tprocess.env.FLUID_LOGGER_PROPS != null\n\t\t? JSON.parse(process.env.FLUID_LOGGER_PROPS)\n\t\t: undefined;\n\nconst _global: any = global;\n\n/**\n * A logger that adds context about the current test run to all events logged through it, like the test variant being\n * run (odsp, r11s, etc) and the name of the current test (while in the context of a particular test running).\n */\nclass FluidTestRunLogger implements ITelemetryBufferedLogger {\n\tprivate currentTestName: string | undefined;\n\n\tsend(event: ITelemetryBaseEvent, logLevel: LogLevel): void {\n\t\t// TODO: Remove when issue #7061 is resolved.\n\t\t// Don't log this event as we generate too much.\n\t\tif (event.eventName === \"fluid:telemetry:RouterliciousDriver:readBlob_end\") {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.currentTestName !== undefined) {\n\t\t\tevent.testName = this.currentTestName;\n\t\t}\n\t\tevent.testVariant = testVariant;\n\t\tthis.parentLogger.send(\n\t\t\t{\n\t\t\t\t...event,\n\t\t\t\t// Setting hostname to pkgName is the behavior we had for a long time, so keeping it just in case.\n\t\t\t\t// But prefer a value set through FLUID_LOGGER_PROPS if it exists.\n\t\t\t\thostName: envLoggerProps?.hostName ?? pkgName,\n\t\t\t\ttestEnvProps: JSON.stringify(envLoggerProps),\n\t\t\t},\n\t\t\tlogLevel,\n\t\t);\n\t}\n\tasync flush(): Promise<void> {\n\t\treturn this.parentLogger.flush();\n\t}\n\tconstructor(private readonly parentLogger: ITelemetryBufferedLogger) {}\n\n\t/**\n\t * Sets the test that is currently running.\n\t * The test name will be included in all events logged through the logger until {@link clearCurrentTest} is called.\n\t * @param testName - The name of the test that is currently running.\n\t */\n\tpublic setCurrentTest(testName: string): void {\n\t\tthis.currentTestName = testName;\n\t}\n\n\t/**\n\t * Clears the test that is currently running.\n\t * Must be called after a given test has completed so that events logged outside the context of a test\n\t * don't include the name of the last test that ran.\n\t */\n\tpublic clearCurrentTest(): void {\n\t\tthis.currentTestName = undefined;\n\t}\n}\nconst nullLogger: ITelemetryBufferedLogger = {\n\tsend: (): void => {},\n\tflush: async (): Promise<void> => {},\n};\n\n// Keep references to the original console functions so we can restore them after each test.\nconst log = console.log;\nconst error = console.log;\nconst warn = console.warn;\n\nlet testLogger: FluidTestRunLogger;\n\n/**\n * The amount of time to wait after logging an event before flushing the logger.\n * This amount was decided after doing tests with different values. See AB#44378 for details.\n */\nconst AFTER_FLUSH_DELAY_MS = 1250;\n\n/**\n * @internal\n */\nexport const mochaHooks = {\n\tasync beforeAll() {\n\t\t// Code in our tests will call the global `getTestLogger` function to get a logger to use.\n\n\t\t// First we call the version of that function that was (potentially) injected dynamicaly to get the logger that it\n\t\t// provides and wrap it with a more intelligent logger which adds test-run-related context to all events logged\n\t\t// through it. See the documentation on `FluidTestRunLogger` for details.\n\t\tlet originalLogger: ITelemetryBufferedLogger;\n\n\t\tif (process.env.FLUID_TEST_LOGGER_PKG_SPECIFIER === undefined) {\n\t\t\toriginalLogger = nullLogger;\n\t\t} else {\n\t\t\tconst { createTestLogger } = await import(process.env.FLUID_TEST_LOGGER_PKG_SPECIFIER);\n\t\t\tif (typeof createTestLogger !== \"function\") {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Expected package '${process.env.FLUID_TEST_LOGGER_PKG_SPECIFIER}' to export a function, but got an object of type '${typeof createTestLogger}' instead`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\toriginalLogger = createTestLogger({\n\t\t\t\t\tafterFlushDelayMs: AFTER_FLUSH_DELAY_MS,\n\t\t\t\t\tthrottleLogging: false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\ttestLogger = new FluidTestRunLogger(originalLogger);\n\n\t\t// Then we redefine `getTestLogger` so it returns the wrapper logger.\n\t\t// NOTE: if we have other global mocha hooks defined somewhere, they include a `beforeEach` hook, and the module in\n\t\t// which they are defined gets loaded before this one, then if that `beforeEach` hook calls `getTestLogger` the logger\n\t\t// it will get will still have a lot of the test-run-related context, but not the name of the current test, because\n\t\t// it will run before the `beforeEach` hook in this file which sets that.\n\t\t_global.getTestLogger = () => testLogger;\n\t},\n\tbeforeEach(this: Mocha.Context) {\n\t\t// If not in verbose mode, suppress console output while the current test runs.\n\t\tif (process.env.FLUID_TEST_VERBOSE === undefined) {\n\t\t\tconsole.log = () => {};\n\t\t\tconsole.error = () => {};\n\t\t\tconsole.warn = () => {};\n\t\t}\n\n\t\tensureTestRunLoggerIsInitialized(testLogger);\n\n\t\tlet testTitle = \"\";\n\t\tif (this.currentTest !== undefined) {\n\t\t\tif (testVariant !== undefined) {\n\t\t\t\tthis.currentTest.title = `[${testVariant}] ${this.currentTest.title}`;\n\t\t\t}\n\t\t\ttestTitle = this.currentTest.fullTitle();\n\t\t}\n\t\ttestLogger.setCurrentTest(testTitle);\n\n\t\ttestLogger.send(\n\t\t\t{\n\t\t\t\tcategory: \"generic\",\n\t\t\t\teventName: \"fluid:telemetry:Test_start\",\n\t\t\t},\n\t\t\tLogLevel.essential,\n\t\t);\n\t},\n\tafterEach(this: Mocha.Context) {\n\t\tensureTestRunLoggerIsInitialized(testLogger);\n\t\ttestLogger.send(\n\t\t\t{\n\t\t\t\tcategory: \"generic\",\n\t\t\t\teventName: \"fluid:telemetry:Test_end\",\n\t\t\t\tstate: this.currentTest?.state,\n\t\t\t\tduration: this.currentTest?.duration,\n\t\t\t\ttimedOut: this.currentTest?.timedOut,\n\t\t\t\terror: this.currentTest?.err?.message,\n\t\t\t\tstack: this.currentTest?.err?.stack,\n\t\t\t},\n\t\t\tLogLevel.essential,\n\t\t);\n\n\t\t// Restore console output now that the current test is done running.\n\t\tconsole.log = log;\n\t\tconsole.error = error;\n\t\tconsole.warn = warn;\n\n\t\t// Clear the current test from the logger. Important so if anything calls `getTestLogger` outside the context of a\n\t\t// test (e.g. during a `before` or `after` hook), it doesn't log events with the name of the last test that ran.\n\t\ttestLogger.clearCurrentTest();\n\t},\n\tasync afterAll(this: Mocha.Context) {\n\t\t// Allow 5 seconds for the logger to flush.\n\t\tthis.timeout(5000);\n\t\t// After all tests ran, flush the logger to ensure all events are sent before the process exits.\n\t\tawait testLogger.flush();\n\t},\n};\n\nglobalThis.getMochaModule = () => {\n\treturn mochaModule;\n};\n\nfunction ensureTestRunLoggerIsInitialized(\n\tloggerToTest: FluidTestRunLogger | undefined,\n): loggerToTest is FluidTestRunLogger {\n\tif (loggerToTest instanceof FluidTestRunLogger) {\n\t\treturn true;\n\t}\n\tthrow new Error(\"Test run logger is not initialized\");\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluid-internal/mocha-test-setup";
|
|
8
|
-
export declare const pkgVersion = "
|
|
8
|
+
export declare const pkgVersion = "3.0.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,qCAAqC,CAAC;AAC1D,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,qCAAqC,CAAC;AAC1D,eAAO,MAAM,UAAU,UAAU,CAAC"}
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-internal/mocha-test-setup\";\nexport const pkgVersion = \"3.0.0\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-internal/mocha-test-setup",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Utilities for Fluid tests",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@fluid-internal/test-driver-definitions": "~
|
|
26
|
-
"@fluidframework/core-interfaces": "~
|
|
25
|
+
"@fluid-internal/test-driver-definitions": "~3.0.0",
|
|
26
|
+
"@fluidframework/core-interfaces": "~3.0.0",
|
|
27
27
|
"mocha": "^11.7.5",
|
|
28
28
|
"source-map-support": "^0.5.21"
|
|
29
29
|
},
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"eslint": "~9.39.1",
|
|
43
43
|
"jiti": "^2.6.1",
|
|
44
44
|
"rimraf": "^6.1.3",
|
|
45
|
-
"typescript": "~
|
|
45
|
+
"typescript": "~6.0.3"
|
|
46
46
|
},
|
|
47
47
|
"fluidBuild": {
|
|
48
|
-
"_tasks_comment": "
|
|
48
|
+
"_tasks_comment": "build:cjs is configured to depend on build:esm task as all CommonJS consumers expect mocha support which is implemented in ESM. Building ESM when CommonJS is requested ensures the implementation expectation is satisfied.",
|
|
49
49
|
"tasks": {
|
|
50
|
-
"
|
|
50
|
+
"build:cjs": {
|
|
51
51
|
"dependsOn": [
|
|
52
|
-
"build:
|
|
52
|
+
"build:esm"
|
|
53
53
|
],
|
|
54
54
|
"script": false
|
|
55
55
|
}
|
|
@@ -60,19 +60,22 @@
|
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "fluid-build . --task build",
|
|
63
|
+
"build:api-reports": "api-extractor run --local --config api-extractor/api-extractor-report.json",
|
|
63
64
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
64
65
|
"build:compile": "fluid-build . --task compile",
|
|
65
66
|
"build:compile:min": "npm run build:compile",
|
|
66
|
-
"build:docs": "api-extractor run --local",
|
|
67
|
-
"build:
|
|
67
|
+
"build:docs": "api-extractor run --local --config api-extractor/api-extractor-model.json",
|
|
68
|
+
"build:esm": "tsc --project ./tsconfig.json",
|
|
68
69
|
"build:genver": "gen-version",
|
|
69
|
-
"check:are-the-types-wrong": "attw --pack . --profile
|
|
70
|
+
"check:are-the-types-wrong": "attw --pack . --profile esm-only --exclude-entrypoints ./mocharc-common",
|
|
70
71
|
"check:biome": "biome check .",
|
|
71
72
|
"check:exports": "concurrently \"npm:check:exports:*\"",
|
|
72
73
|
"check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
|
|
73
74
|
"check:exports:esm:index": "api-extractor run --config api-extractor/api-extractor-lint-index.esm.json",
|
|
74
75
|
"check:format": "npm run check:biome",
|
|
75
|
-
"
|
|
76
|
+
"check:types:inexactOptionalPropertyTypes": "tsc --project ./tsconfig.json --noEmit --exactOptionalPropertyTypes false --skipLibCheck --emitDeclarationOnly false --tsBuildInfoFile ./tsconfig.inexactOptionalPropertyTypes.tsbuildinfo",
|
|
77
|
+
"ci:build:api-reports": "api-extractor run --config api-extractor/api-extractor-report.json",
|
|
78
|
+
"ci:build:docs": "api-extractor run --config api-extractor/api-extractor-model.json",
|
|
76
79
|
"clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp",
|
|
77
80
|
"eslint": "eslint --quiet --format stylish src",
|
|
78
81
|
"eslint:fix": "eslint --quiet --format stylish src --fix --fix-type problem,suggestion,layout",
|
package/src/mochaHooks.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { ITelemetryBufferedLogger } from "@fluid-internal/test-driver-definitions";
|
|
7
7
|
import type { ITelemetryBaseEvent } from "@fluidframework/core-interfaces";
|
|
8
|
+
import { LogLevel } from "@fluidframework/core-interfaces";
|
|
8
9
|
import * as mochaModule from "mocha";
|
|
9
10
|
|
|
10
11
|
import { pkgName } from "./packageVersion.js";
|
|
@@ -31,7 +32,7 @@ const _global: any = global;
|
|
|
31
32
|
class FluidTestRunLogger implements ITelemetryBufferedLogger {
|
|
32
33
|
private currentTestName: string | undefined;
|
|
33
34
|
|
|
34
|
-
send(event: ITelemetryBaseEvent): void {
|
|
35
|
+
send(event: ITelemetryBaseEvent, logLevel: LogLevel): void {
|
|
35
36
|
// TODO: Remove when issue #7061 is resolved.
|
|
36
37
|
// Don't log this event as we generate too much.
|
|
37
38
|
if (event.eventName === "fluid:telemetry:RouterliciousDriver:readBlob_end") {
|
|
@@ -42,13 +43,16 @@ class FluidTestRunLogger implements ITelemetryBufferedLogger {
|
|
|
42
43
|
event.testName = this.currentTestName;
|
|
43
44
|
}
|
|
44
45
|
event.testVariant = testVariant;
|
|
45
|
-
this.parentLogger.send(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
this.parentLogger.send(
|
|
47
|
+
{
|
|
48
|
+
...event,
|
|
49
|
+
// Setting hostname to pkgName is the behavior we had for a long time, so keeping it just in case.
|
|
50
|
+
// But prefer a value set through FLUID_LOGGER_PROPS if it exists.
|
|
51
|
+
hostName: envLoggerProps?.hostName ?? pkgName,
|
|
52
|
+
testEnvProps: JSON.stringify(envLoggerProps),
|
|
53
|
+
},
|
|
54
|
+
logLevel,
|
|
55
|
+
);
|
|
52
56
|
}
|
|
53
57
|
async flush(): Promise<void> {
|
|
54
58
|
return this.parentLogger.flush();
|
|
@@ -147,22 +151,28 @@ export const mochaHooks = {
|
|
|
147
151
|
}
|
|
148
152
|
testLogger.setCurrentTest(testTitle);
|
|
149
153
|
|
|
150
|
-
testLogger.send(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
testLogger.send(
|
|
155
|
+
{
|
|
156
|
+
category: "generic",
|
|
157
|
+
eventName: "fluid:telemetry:Test_start",
|
|
158
|
+
},
|
|
159
|
+
LogLevel.essential,
|
|
160
|
+
);
|
|
154
161
|
},
|
|
155
162
|
afterEach(this: Mocha.Context) {
|
|
156
163
|
ensureTestRunLoggerIsInitialized(testLogger);
|
|
157
|
-
testLogger.send(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
testLogger.send(
|
|
165
|
+
{
|
|
166
|
+
category: "generic",
|
|
167
|
+
eventName: "fluid:telemetry:Test_end",
|
|
168
|
+
state: this.currentTest?.state,
|
|
169
|
+
duration: this.currentTest?.duration,
|
|
170
|
+
timedOut: this.currentTest?.timedOut,
|
|
171
|
+
error: this.currentTest?.err?.message,
|
|
172
|
+
stack: this.currentTest?.err?.stack,
|
|
173
|
+
},
|
|
174
|
+
LogLevel.essential,
|
|
175
|
+
);
|
|
166
176
|
|
|
167
177
|
// Restore console output now that the current test is done running.
|
|
168
178
|
console.log = log;
|
package/src/packageVersion.ts
CHANGED
package/tsconfig.json
CHANGED