@fluid-internal/mocha-test-setup 2.74.0-368706 → 2.74.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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluid-internal/mocha-test-setup
2
2
 
3
+ ## 2.74.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.73.0
4
8
 
5
9
  Dependency updates only.
@@ -1 +1 @@
1
- {"version":3,"file":"mochaHooks.js","sourceRoot":"","sources":["../src/mochaHooks.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,mDAAqC;AAErC,2DAA8C;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;IAGvB,IAAI,CAAC,KAA0B;QAC9B,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,CAAC;YAC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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) {\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() {\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) {\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() {\n\t\tthis.currentTestName = undefined;\n\t}\n}\nconst nullLogger: ITelemetryBufferedLogger = {\n\tsend: () => {},\n\tflush: async () => {},\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,mDAAqC;AAErC,2DAA8C;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;IAGvB,IAAI,CAAC,KAA0B;QAC9B,6CAA6C;QAC7C,gDAAgD;QAChD,IAAI,KAAK,CAAC,SAAS,KAAK,kDAAkD,EAAE,CAAC;YAC5E,OAAO;QACR,CAAC;QAED,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,E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AY,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"]}
@@ -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 = "2.74.0-368706";
8
+ export declare const pkgVersion = "2.74.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,kBAAkB,CAAC"}
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,WAAW,CAAC"}
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluid-internal/mocha-test-setup";
11
- exports.pkgVersion = "2.74.0-368706";
11
+ exports.pkgVersion = "2.74.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,kCAAkC,CAAC;AAC7C,QAAA,UAAU,GAAG,eAAe,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 = \"2.74.0-368706\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,kCAAkC,CAAC;AAC7C,QAAA,UAAU,GAAG,QAAQ,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 = \"2.74.0\";\n"]}
@@ -0,0 +1,11 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * GENERATED FILE - DO NOT EDIT DIRECTLY.
4
+ * To regenerate: pnpm tsx scripts/generate-flat-eslint-configs.ts --typescript
5
+ */
6
+ import type { Linter } from "eslint";
7
+ import { minimalDeprecated } from "../../../common/build/eslint-config-fluid/flat.mts";
8
+
9
+ const config: Linter.Config[] = [...minimalDeprecated];
10
+
11
+ export default config;
@@ -1 +1 @@
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rC,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,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) {\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() {\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) {\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() {\n\t\tthis.currentTestName = undefined;\n\t}\n}\nconst nullLogger: ITelemetryBufferedLogger = {\n\tsend: () => {},\n\tflush: async () => {},\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,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;IAGvB,IAAI,CAAC,KAA0B;QAC9B,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,CAAC;YACtB,GAAG,KAAK;YACR,kGAAkG;YAClG,kEAAkE;YAClE,QAA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f,QAAQ,EAAE,SAAS;YACnB,SAAS,EAAE,4BAA4B;SACvC,CAAC,CAAC;IACJ,CAAC;IACD,SAAS;QACR,gCAAgC,CAAC,UAAU,CAAC,CAAC;QAC7C,UAAU,CAAC,IAAI,CAAC;YACf,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,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"]}
@@ -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 = "2.74.0-368706";
8
+ export declare const pkgVersion = "2.74.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,kBAAkB,CAAC"}
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,WAAW,CAAC"}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluid-internal/mocha-test-setup";
8
- export const pkgVersion = "2.74.0-368706";
8
+ export const pkgVersion = "2.74.0";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -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,eAAe,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 = \"2.74.0-368706\";\n"]}
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,QAAQ,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 = \"2.74.0\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-internal/mocha-test-setup",
3
- "version": "2.74.0-368706",
3
+ "version": "2.74.0",
4
4
  "description": "Utilities for Fluid tests",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -30,24 +30,25 @@
30
30
  "main": "dist/index.js",
31
31
  "types": "dist/index.d.ts",
32
32
  "dependencies": {
33
- "@fluid-internal/test-driver-definitions": "2.74.0-368706",
34
- "@fluidframework/core-interfaces": "2.74.0-368706",
33
+ "@fluid-internal/test-driver-definitions": "~2.74.0",
34
+ "@fluidframework/core-interfaces": "~2.74.0",
35
35
  "mocha": "^10.8.2",
36
36
  "source-map-support": "^0.5.21"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@arethetypeswrong/cli": "^0.17.1",
40
40
  "@biomejs/biome": "~1.9.3",
41
- "@fluid-tools/build-cli": "^0.60.0",
41
+ "@fluid-tools/build-cli": "^0.61.0",
42
42
  "@fluidframework/build-common": "^2.0.3",
43
- "@fluidframework/build-tools": "^0.60.0",
44
- "@fluidframework/eslint-config-fluid": "2.74.0-368706",
43
+ "@fluidframework/build-tools": "^0.61.0",
44
+ "@fluidframework/eslint-config-fluid": "~2.74.0",
45
45
  "@microsoft/api-extractor": "7.52.11",
46
46
  "@types/mocha": "^10.0.10",
47
47
  "@types/node": "^18.19.0",
48
48
  "concurrently": "^8.2.1",
49
49
  "copyfiles": "^2.4.1",
50
50
  "eslint": "~8.57.1",
51
+ "jiti": "^2.6.1",
51
52
  "rimraf": "^4.4.0",
52
53
  "typescript": "~5.4.5"
53
54
  },
package/src/mochaHooks.ts CHANGED
@@ -31,7 +31,7 @@ const _global: any = global;
31
31
  class FluidTestRunLogger implements ITelemetryBufferedLogger {
32
32
  private currentTestName: string | undefined;
33
33
 
34
- send(event: ITelemetryBaseEvent) {
34
+ send(event: ITelemetryBaseEvent): void {
35
35
  // TODO: Remove when issue #7061 is resolved.
36
36
  // Don't log this event as we generate too much.
37
37
  if (event.eventName === "fluid:telemetry:RouterliciousDriver:readBlob_end") {
@@ -50,7 +50,7 @@ class FluidTestRunLogger implements ITelemetryBufferedLogger {
50
50
  testEnvProps: JSON.stringify(envLoggerProps),
51
51
  });
52
52
  }
53
- async flush() {
53
+ async flush(): Promise<void> {
54
54
  return this.parentLogger.flush();
55
55
  }
56
56
  constructor(private readonly parentLogger: ITelemetryBufferedLogger) {}
@@ -60,7 +60,7 @@ class FluidTestRunLogger implements ITelemetryBufferedLogger {
60
60
  * The test name will be included in all events logged through the logger until {@link clearCurrentTest} is called.
61
61
  * @param testName - The name of the test that is currently running.
62
62
  */
63
- public setCurrentTest(testName: string) {
63
+ public setCurrentTest(testName: string): void {
64
64
  this.currentTestName = testName;
65
65
  }
66
66
 
@@ -69,13 +69,13 @@ class FluidTestRunLogger implements ITelemetryBufferedLogger {
69
69
  * Must be called after a given test has completed so that events logged outside the context of a test
70
70
  * don't include the name of the last test that ran.
71
71
  */
72
- public clearCurrentTest() {
72
+ public clearCurrentTest(): void {
73
73
  this.currentTestName = undefined;
74
74
  }
75
75
  }
76
76
  const nullLogger: ITelemetryBufferedLogger = {
77
- send: () => {},
78
- flush: async () => {},
77
+ send: (): void => {},
78
+ flush: async (): Promise<void> => {},
79
79
  };
80
80
 
81
81
  // Keep references to the original console functions so we can restore them after each test.
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluid-internal/mocha-test-setup";
9
- export const pkgVersion = "2.74.0-368706";
9
+ export const pkgVersion = "2.74.0";