@fluid-internal/mocha-test-setup 2.4.0 → 2.5.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.5.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.4.0
4
8
 
5
9
  Dependency updates only.
@@ -1 +1 @@
1
- {"version":3,"file":"mochaHooks.d.ts","sourceRoot":"","sources":["../src/mochaHooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AA0DH;;GAEG;AACH,eAAO,MAAM,UAAU;;qBAoBL,MAAM,OAAO;oBAoBd,MAAM,OAAO;CAuB7B,CAAC"}
1
+ {"version":3,"file":"mochaHooks.d.ts","sourceRoot":"","sources":["../src/mochaHooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAgEH;;GAEG;AACH,eAAO,MAAM,UAAU;;qBAoBL,MAAM,OAAO;oBAoBd,MAAM,OAAO;CAuB7B,CAAC"}
@@ -36,7 +36,7 @@ const packageVersion_js_1 = require("./packageVersion.js");
36
36
  // as this will incur a perf impact when errors are
37
37
  // thrown and will take more storage in any logging sink
38
38
  // https://v8.dev/docs/stack-trace-api
39
- Error.stackTraceLimit = Infinity;
39
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
40
40
  const testVariant = process.env.FLUID_TEST_VARIANT;
41
41
  const propsDict = process.env.FLUID_LOGGER_PROPS != null
42
42
  ? JSON.parse(process.env.FLUID_LOGGER_PROPS)
@@ -54,7 +54,13 @@ class TestLogger {
54
54
  event.testName = this.testName ?? currentTestName;
55
55
  event.testVariant = testVariant;
56
56
  event.hostName = packageVersion_js_1.pkgName;
57
- this.parentLogger.send({ ...event, ...propsDict });
57
+ this.parentLogger.send({
58
+ ...event,
59
+ // If there's an override for the hostName in FLUID_LOGGER_PROPS,
60
+ // display that in the telemetry instead of the package name.
61
+ hostName: propsDict?.hostName ?? packageVersion_js_1.pkgName,
62
+ details: JSON.stringify(propsDict),
63
+ });
58
64
  }
59
65
  async flush() {
60
66
  return this.parentLogger.flush();
@@ -1 +1 @@
1
- {"version":3,"file":"mochaHooks.js","sourceRoot":"","sources":["../src/mochaHooks.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,mDAAqC;AAErC,2DAA8C;AAE9C,yDAAyD;AACzD,0DAA0D;AAC1D,sDAAsD;AACtD,mDAAmD;AACnD,wDAAwD;AACxD,sCAAsC;AACtC,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;AAEjC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;AACnD,MAAM,SAAS,GACd,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;AAC5B,MAAM,UAAU;IACf,IAAI,CAAC,KAA0B;QAC9B,6CAA6C;QAC7C,gDAAgD;QAChD,IAAI,KAAK,CAAC,SAAS,KAAK,kDAAkD,EAAE,CAAC;YAC5E,OAAO;QACR,CAAC;QAED,gGAAgG;QAChG,qFAAqF;QACrF,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,eAAe,CAAC;QAClD,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;QAChC,KAAK,CAAC,QAAQ,GAAG,2BAAO,CAAC;QACzB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;IACpD,CAAC;IACD,KAAK,CAAC,KAAK;QACV,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;IACD,YACkB,YAAsC,EAC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AAC;QACzB,CAAC;QACD,4GAA4G;QAC5G,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,CAAC;QAChD,iBAAiB,GAAG,SAAS,CAAC;QAE9B,2BAA2B;QAC3B,cAAc,CAAC,IAAI,CAAC;YACnB,QAAQ,EAAE,SAAS;YACnB,SAAS,EAAE,4BAA4B;YACvC,QAAQ,EAAE,eAAe;YACzB,WAAW;YACX,QAAQ,EAAE,2BAAO;SACjB,CAAC,CAAC;IACJ,CAAC;IACD,SAAS;QACR,yBAAyB;QACzB,cAAc,CAAC,IAAI,CAAC;YACnB,QAAQ,EAAE,SAAS;YACnB,SAAS,EAAE,0BAA0B;YACrC,QAAQ,EAAE,eAAe;YACzB,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK;YAC9B,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ;YACpC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ;YACpC,WAAW;YACX,QAAQ,EAAE,2BAAO;YACjB,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO;YACrC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK;SACnC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC;QAClB,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACtB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QAEpB,sDAAsD;QACtD,iBAAiB,GAAG,SAAS,CAAC;QAC9B,eAAe,GAAG,SAAS,CAAC;IAC7B,CAAC;CACD,CAAC;AAEF,UAAU,CAAC,cAAc,GAAG,GAAG,EAAE;IAChC,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBufferedLogger } from \"@fluid-internal/test-driver-definitions\";\nimport { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport * as mochaModule from \"mocha\";\n\nimport { pkgName } from \"./packageVersion.js\";\n\n// this will enabling capturing the full stack for errors\n// since this is test capturing the full stack is worth it\n// in non-test environment we need to be more cautious\n// 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 = Infinity;\n\nconst testVariant = process.env.FLUID_TEST_VARIANT;\nconst propsDict =\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;\nclass TestLogger implements ITelemetryBufferedLogger {\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\t// The test logger is currently instantiated once and for each event triggered between begin and\n\t\t// end of a test, in case the testName is undefined, we will use the currentTestName.\n\t\tevent.testName = this.testName ?? currentTestName;\n\t\tevent.testVariant = testVariant;\n\t\tevent.hostName = pkgName;\n\t\tthis.parentLogger.send({ ...event, ...propsDict });\n\t}\n\tasync flush() {\n\t\treturn this.parentLogger.flush();\n\t}\n\tconstructor(\n\t\tprivate readonly parentLogger: ITelemetryBufferedLogger,\n\t\tprivate readonly testName: string | undefined,\n\t) {}\n}\nconst nullLogger: ITelemetryBufferedLogger = {\n\tsend: () => {},\n\tflush: async () => {},\n};\n\nconst log = console.log;\nconst error = console.log;\nconst warn = console.warn;\nlet currentTestLogger: ITelemetryBufferedLogger | undefined;\nlet currentTestName: string | undefined;\nlet originalLogger: ITelemetryBufferedLogger;\n\n/**\n * @internal\n */\nexport const mochaHooks = {\n\tbeforeAll() {\n\t\toriginalLogger = _global.getTestLogger?.() ?? nullLogger;\n\t\t_global.getTestLogger = () => {\n\t\t\t// If a current test logger exists, use that. Otherwise, create a new one. This should become the\n\t\t\t// current test logger if this function is running in a context which understands the current test.\n\t\t\t// Otherwise, just return the created TestLogger. (This happens e.g. if someone calls `getTestLogger`\n\t\t\t// in a `before` or `after` hook, due to the order in which mocha hooks run)\n\t\t\tif (currentTestLogger !== undefined) {\n\t\t\t\treturn currentTestLogger;\n\t\t\t}\n\n\t\t\tconst testLogger = new TestLogger(originalLogger, currentTestName);\n\t\t\tif (currentTestName !== undefined) {\n\t\t\t\tcurrentTestLogger = testLogger;\n\t\t\t}\n\n\t\t\treturn testLogger;\n\t\t};\n\t},\n\tbeforeEach(this: Mocha.Context) {\n\t\t// Suppress console.log if not verbose mode\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\t\t// save the test name can and clear the previous logger (if afterEach didn't get ran and it got left behind)\n\t\tcurrentTestName = this.currentTest?.fullTitle();\n\t\tcurrentTestLogger = undefined;\n\n\t\t// send event on test start\n\t\toriginalLogger.send({\n\t\t\tcategory: \"generic\",\n\t\t\teventName: \"fluid:telemetry:Test_start\",\n\t\t\ttestName: currentTestName,\n\t\t\ttestVariant,\n\t\t\thostName: pkgName,\n\t\t});\n\t},\n\tafterEach(this: Mocha.Context) {\n\t\t// send event on test end\n\t\toriginalLogger.send({\n\t\t\tcategory: \"generic\",\n\t\t\teventName: \"fluid:telemetry:Test_end\",\n\t\t\ttestName: currentTestName,\n\t\t\tstate: this.currentTest?.state,\n\t\t\tduration: this.currentTest?.duration,\n\t\t\ttimedOut: this.currentTest?.timedOut,\n\t\t\ttestVariant,\n\t\t\thostName: pkgName,\n\t\t\terror: this.currentTest?.err?.message,\n\t\t\tstack: this.currentTest?.err?.stack,\n\t\t});\n\n\t\tconsole.log = log;\n\t\tconsole.error = error;\n\t\tconsole.warn = warn;\n\n\t\t// clear the test logger and test name after each test\n\t\tcurrentTestLogger = undefined;\n\t\tcurrentTestName = undefined;\n\t},\n};\n\nglobal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zB,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QACzB,CAAC;QACD,4GAA4G;QAC5G,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,CAAC;QAChD,iBAAiB,GAAG,SAAS,CAAC;QAE9B,2BAA2B;QAC3B,cAAc,CAAC,IAAI,CAAC;YACnB,QAAQ,EAAE,SAAS;YACnB,SAAS,EAAE,4BAA4B;YACvC,QAAQ,EAAE,eAAe;YACzB,WAAW;YACX,QAAQ,EAAE,2BAAO;SACjB,CAAC,CAAC;IACJ,CAAC;IACD,SAAS;QACR,yBAAyB;QACzB,cAAc,CAAC,IAAI,CAAC;YACnB,QAAQ,EAAE,SAAS;YACnB,SAAS,EAAE,0BAA0B;YACrC,QAAQ,EAAE,eAAe;YACzB,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK;YAC9B,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ;YACpC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ;YACpC,WAAW;YACX,QAAQ,EAAE,2BAAO;YACjB,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO;YACrC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK;SACnC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC;QAClB,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACtB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QAEpB,sDAAsD;QACtD,iBAAiB,GAAG,SAAS,CAAC;QAC9B,eAAe,GAAG,SAAS,CAAC;IAC7B,CAAC;CACD,CAAC;AAEF,UAAU,CAAC,cAAc,GAAG,GAAG,EAAE;IAChC,OAAO,WAAW,CAAC;AACpB,CAAC,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 enabling capturing the full stack for errors\n// since this is test capturing the full stack is worth it\n// in non-test environment we need to be more cautious\n// 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 propsDict =\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;\nclass TestLogger implements ITelemetryBufferedLogger {\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\t// The test logger is currently instantiated once and for each event triggered between begin and\n\t\t// end of a test, in case the testName is undefined, we will use the currentTestName.\n\t\tevent.testName = this.testName ?? currentTestName;\n\t\tevent.testVariant = testVariant;\n\t\tevent.hostName = pkgName;\n\t\tthis.parentLogger.send({\n\t\t\t...event,\n\t\t\t// If there's an override for the hostName in FLUID_LOGGER_PROPS,\n\t\t\t// display that in the telemetry instead of the package name.\n\t\t\thostName: propsDict?.hostName ?? pkgName,\n\t\t\tdetails: JSON.stringify(propsDict),\n\t\t});\n\t}\n\tasync flush() {\n\t\treturn this.parentLogger.flush();\n\t}\n\tconstructor(\n\t\tprivate readonly parentLogger: ITelemetryBufferedLogger,\n\t\tprivate readonly testName: string | undefined,\n\t) {}\n}\nconst nullLogger: ITelemetryBufferedLogger = {\n\tsend: () => {},\n\tflush: async () => {},\n};\n\nconst log = console.log;\nconst error = console.log;\nconst warn = console.warn;\nlet currentTestLogger: ITelemetryBufferedLogger | undefined;\nlet currentTestName: string | undefined;\nlet originalLogger: ITelemetryBufferedLogger;\n\n/**\n * @internal\n */\nexport const mochaHooks = {\n\tbeforeAll() {\n\t\toriginalLogger = _global.getTestLogger?.() ?? nullLogger;\n\t\t_global.getTestLogger = () => {\n\t\t\t// If a current test logger exists, use that. Otherwise, create a new one. This should become the\n\t\t\t// current test logger if this function is running in a context which understands the current test.\n\t\t\t// Otherwise, just return the created TestLogger. (This happens e.g. if someone calls `getTestLogger`\n\t\t\t// in a `before` or `after` hook, due to the order in which mocha hooks run)\n\t\t\tif (currentTestLogger !== undefined) {\n\t\t\t\treturn currentTestLogger;\n\t\t\t}\n\n\t\t\tconst testLogger = new TestLogger(originalLogger, currentTestName);\n\t\t\tif (currentTestName !== undefined) {\n\t\t\t\tcurrentTestLogger = testLogger;\n\t\t\t}\n\n\t\t\treturn testLogger;\n\t\t};\n\t},\n\tbeforeEach(this: Mocha.Context) {\n\t\t// Suppress console.log if not verbose mode\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\t\t// save the test name can and clear the previous logger (if afterEach didn't get ran and it got left behind)\n\t\tcurrentTestName = this.currentTest?.fullTitle();\n\t\tcurrentTestLogger = undefined;\n\n\t\t// send event on test start\n\t\toriginalLogger.send({\n\t\t\tcategory: \"generic\",\n\t\t\teventName: \"fluid:telemetry:Test_start\",\n\t\t\ttestName: currentTestName,\n\t\t\ttestVariant,\n\t\t\thostName: pkgName,\n\t\t});\n\t},\n\tafterEach(this: Mocha.Context) {\n\t\t// send event on test end\n\t\toriginalLogger.send({\n\t\t\tcategory: \"generic\",\n\t\t\teventName: \"fluid:telemetry:Test_end\",\n\t\t\ttestName: currentTestName,\n\t\t\tstate: this.currentTest?.state,\n\t\t\tduration: this.currentTest?.duration,\n\t\t\ttimedOut: this.currentTest?.timedOut,\n\t\t\ttestVariant,\n\t\t\thostName: pkgName,\n\t\t\terror: this.currentTest?.err?.message,\n\t\t\tstack: this.currentTest?.err?.stack,\n\t\t});\n\n\t\tconsole.log = log;\n\t\tconsole.error = error;\n\t\tconsole.warn = warn;\n\n\t\t// clear the test logger and test name after each test\n\t\tcurrentTestLogger = undefined;\n\t\tcurrentTestName = undefined;\n\t},\n};\n\nglobalThis.getMochaModule = () => {\n\treturn mochaModule;\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.4.0";
8
+ export declare const pkgVersion = "2.5.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -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.4.0";
11
+ exports.pkgVersion = "2.5.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,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 = \"2.4.0\";\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,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 = \"2.5.0\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"mochaHooks.d.ts","sourceRoot":"","sources":["../src/mochaHooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AA0DH;;GAEG;AACH,eAAO,MAAM,UAAU;;qBAoBL,MAAM,OAAO;oBAoBd,MAAM,OAAO;CAuB7B,CAAC"}
1
+ {"version":3,"file":"mochaHooks.d.ts","sourceRoot":"","sources":["../src/mochaHooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAgEH;;GAEG;AACH,eAAO,MAAM,UAAU;;qBAoBL,MAAM,OAAO;oBAoBd,MAAM,OAAO;CAuB7B,CAAC"}
package/lib/mochaHooks.js CHANGED
@@ -10,7 +10,7 @@ import { pkgName } from "./packageVersion.js";
10
10
  // as this will incur a perf impact when errors are
11
11
  // thrown and will take more storage in any logging sink
12
12
  // https://v8.dev/docs/stack-trace-api
13
- Error.stackTraceLimit = Infinity;
13
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
14
14
  const testVariant = process.env.FLUID_TEST_VARIANT;
15
15
  const propsDict = process.env.FLUID_LOGGER_PROPS != null
16
16
  ? JSON.parse(process.env.FLUID_LOGGER_PROPS)
@@ -28,7 +28,13 @@ class TestLogger {
28
28
  event.testName = this.testName ?? currentTestName;
29
29
  event.testVariant = testVariant;
30
30
  event.hostName = pkgName;
31
- this.parentLogger.send({ ...event, ...propsDict });
31
+ this.parentLogger.send({
32
+ ...event,
33
+ // If there's an override for the hostName in FLUID_LOGGER_PROPS,
34
+ // display that in the telemetry instead of the package name.
35
+ hostName: propsDict?.hostName ?? pkgName,
36
+ details: JSON.stringify(propsDict),
37
+ });
32
38
  }
33
39
  async flush() {
34
40
  return this.par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IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,CAAC;QAChD,iBAAiB,GAAG,SAAS,CAAC;QAE9B,2BAA2B;QAC3B,cAAc,CAAC,IAAI,CAAC;YACnB,QAAQ,EAAE,SAAS;YACnB,SAAS,EAAE,4BAA4B;YACvC,QAAQ,EAAE,eAAe;YACzB,WAAW;YACX,QAAQ,EAAE,OAAO;SACjB,CAAC,CAAC;IACJ,CAAC;IACD,SAAS;QACR,yBAAyB;QACzB,cAAc,CAAC,IAAI,CAAC;YACnB,QAAQ,EAAE,SAAS;YACnB,SAAS,EAAE,0BAA0B;YACrC,QAAQ,EAAE,eAAe;YACzB,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK;YAC9B,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ;YACpC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ;YACpC,WAAW;YACX,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO;YACrC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK;SACnC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC;QAClB,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACtB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QAEpB,sDAAsD;QACtD,iBAAiB,GAAG,SAAS,CAAC;QAC9B,eAAe,GAAG,SAAS,CAAC;IAC7B,CAAC;CACD,CAAC;AAEF,UAAU,CAAC,cAAc,GAAG,GAAG,EAAE;IAChC,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBufferedLogger } from \"@fluid-internal/test-driver-definitions\";\nimport { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport * as mochaModule from \"mocha\";\n\nimport { pkgName } from \"./packageVersion.js\";\n\n// this will enabling capturing the full stack for errors\n// since this is test capturing the full stack is worth it\n// in non-test environment we need to be more cautious\n// 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 = Infinity;\n\nconst testVariant = process.env.FLUID_TEST_VARIANT;\nconst propsDict =\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;\nclass TestLogger implements ITelemetryBufferedLogger {\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\t// The test logger is currently instantiated once and for each event triggered between begin and\n\t\t// end of a test, in case the testName is undefined, we will use the currentTestName.\n\t\tevent.testName = this.testName ?? currentTestName;\n\t\tevent.testVariant = testVariant;\n\t\tevent.hostName = pkgName;\n\t\tthis.parentLogger.send({ ...event, ...propsDict });\n\t}\n\tasync flush() {\n\t\treturn this.parentLogger.flush();\n\t}\n\tconstructor(\n\t\tprivate readonly parentLogger: ITelemetryBufferedLogger,\n\t\tprivate readonly testName: string | undefined,\n\t) {}\n}\nconst nullLogger: ITelemetryBufferedLogger = {\n\tsend: () => {},\n\tflush: async () => {},\n};\n\nconst log = console.log;\nconst error = console.log;\nconst warn = console.warn;\nlet currentTestLogger: ITelemetryBufferedLogger | undefined;\nlet currentTestName: string | undefined;\nlet originalLogger: ITelemetryBufferedLogger;\n\n/**\n * @internal\n */\nexport const mochaHooks = {\n\tbeforeAll() {\n\t\toriginalLogger = _global.getTestLogger?.() ?? nullLogger;\n\t\t_global.getTestLogger = () => {\n\t\t\t// If a current test logger exists, use that. Otherwise, create a new one. This should become the\n\t\t\t// current test logger if this function is running in a context which understands the current test.\n\t\t\t// Otherwise, just return the created TestLogger. (This happens e.g. if someone calls `getTestLogger`\n\t\t\t// in a `before` or `after` hook, due to the order in which mocha hooks run)\n\t\t\tif (currentTestLogger !== undefined) {\n\t\t\t\treturn currentTestLogger;\n\t\t\t}\n\n\t\t\tconst testLogger = new TestLogger(originalLogger, currentTestName);\n\t\t\tif (currentTestName !== undefined) {\n\t\t\t\tcurrentTestLogger = testLogger;\n\t\t\t}\n\n\t\t\treturn testLogger;\n\t\t};\n\t},\n\tbeforeEach(this: Mocha.Context) {\n\t\t// Suppress console.log if not verbose mode\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\t\t// save the test name can and clear the previous logger (if afterEach didn't get ran and it got left behind)\n\t\tcurrentTestName = this.currentTest?.fullTitle();\n\t\tcurrentTestLogger = undefined;\n\n\t\t// send event on test start\n\t\toriginalLogger.send({\n\t\t\tcategory: \"generic\",\n\t\t\teventName: \"fluid:telemetry:Test_start\",\n\t\t\ttestName: currentTestName,\n\t\t\ttestVariant,\n\t\t\thostName: pkgName,\n\t\t});\n\t},\n\tafterEach(this: Mocha.Context) {\n\t\t// send event on test end\n\t\toriginalLogger.send({\n\t\t\tcategory: \"generic\",\n\t\t\teventName: \"fluid:telemetry:Test_end\",\n\t\t\ttestName: currentTestName,\n\t\t\tstate: this.currentTest?.state,\n\t\t\tduration: this.currentTest?.duration,\n\t\t\ttimedOut: this.currentTest?.timedOut,\n\t\t\ttestVariant,\n\t\t\thostName: pkgName,\n\t\t\terror: this.currentTest?.err?.message,\n\t\t\tstack: this.currentTest?.err?.stack,\n\t\t});\n\n\t\tconsole.log = log;\n\t\tconsole.error = error;\n\t\tconsole.warn = warn;\n\n\t\t// clear the test logger and test name after each test\n\t\tcurrentTestLogger = undefined;\n\t\tcurrentTestName = undefined;\n\t},\n};\n\nglobalThis.getMochaModule = () => {\n\treturn mochaModule;\n};\n"]}
1
+ {"version":3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,CAAC,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QACzB,CAAC;QACD,4GAA4G;QAC5G,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,CAAC;QAChD,iBAAiB,GAAG,SAAS,CAAC;QAE9B,2BAA2B;QAC3B,cAAc,CAAC,IAAI,CAAC;YACnB,QAAQ,EAAE,SAAS;YACnB,SAAS,EAAE,4BAA4B;YACvC,QAAQ,EAAE,eAAe;YACzB,WAAW;YACX,QAAQ,EAAE,OAAO;SACjB,CAAC,CAAC;IACJ,CAAC;IACD,SAAS;QACR,yBAAyB;QACzB,cAAc,CAAC,IAAI,CAAC;YACnB,QAAQ,EAAE,SAAS;YACnB,SAAS,EAAE,0BAA0B;YACrC,QAAQ,EAAE,eAAe;YACzB,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK;YAC9B,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ;YACpC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ;YACpC,WAAW;YACX,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO;YACrC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK;SACnC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC;QAClB,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACtB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QAEpB,sDAAsD;QACtD,iBAAiB,GAAG,SAAS,CAAC;QAC9B,eAAe,GAAG,SAAS,CAAC;IAC7B,CAAC;CACD,CAAC;AAEF,UAAU,CAAC,cAAc,GAAG,GAAG,EAAE;IAChC,OAAO,WAAW,CAAC;AACpB,CAAC,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 enabling capturing the full stack for errors\n// since this is test capturing the full stack is worth it\n// in non-test environment we need to be more cautious\n// 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 propsDict =\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;\nclass TestLogger implements ITelemetryBufferedLogger {\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\t// The test logger is currently instantiated once and for each event triggered between begin and\n\t\t// end of a test, in case the testName is undefined, we will use the currentTestName.\n\t\tevent.testName = this.testName ?? currentTestName;\n\t\tevent.testVariant = testVariant;\n\t\tevent.hostName = pkgName;\n\t\tthis.parentLogger.send({\n\t\t\t...event,\n\t\t\t// If there's an override for the hostName in FLUID_LOGGER_PROPS,\n\t\t\t// display that in the telemetry instead of the package name.\n\t\t\thostName: propsDict?.hostName ?? pkgName,\n\t\t\tdetails: JSON.stringify(propsDict),\n\t\t});\n\t}\n\tasync flush() {\n\t\treturn this.parentLogger.flush();\n\t}\n\tconstructor(\n\t\tprivate readonly parentLogger: ITelemetryBufferedLogger,\n\t\tprivate readonly testName: string | undefined,\n\t) {}\n}\nconst nullLogger: ITelemetryBufferedLogger = {\n\tsend: () => {},\n\tflush: async () => {},\n};\n\nconst log = console.log;\nconst error = console.log;\nconst warn = console.warn;\nlet currentTestLogger: ITelemetryBufferedLogger | undefined;\nlet currentTestName: string | undefined;\nlet originalLogger: ITelemetryBufferedLogger;\n\n/**\n * @internal\n */\nexport const mochaHooks = {\n\tbeforeAll() {\n\t\toriginalLogger = _global.getTestLogger?.() ?? nullLogger;\n\t\t_global.getTestLogger = () => {\n\t\t\t// If a current test logger exists, use that. Otherwise, create a new one. This should become the\n\t\t\t// current test logger if this function is running in a context which understands the current test.\n\t\t\t// Otherwise, just return the created TestLogger. (This happens e.g. if someone calls `getTestLogger`\n\t\t\t// in a `before` or `after` hook, due to the order in which mocha hooks run)\n\t\t\tif (currentTestLogger !== undefined) {\n\t\t\t\treturn currentTestLogger;\n\t\t\t}\n\n\t\t\tconst testLogger = new TestLogger(originalLogger, currentTestName);\n\t\t\tif (currentTestName !== undefined) {\n\t\t\t\tcurrentTestLogger = testLogger;\n\t\t\t}\n\n\t\t\treturn testLogger;\n\t\t};\n\t},\n\tbeforeEach(this: Mocha.Context) {\n\t\t// Suppress console.log if not verbose mode\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\t\t// save the test name can and clear the previous logger (if afterEach didn't get ran and it got left behind)\n\t\tcurrentTestName = this.currentTest?.fullTitle();\n\t\tcurrentTestLogger = undefined;\n\n\t\t// send event on test start\n\t\toriginalLogger.send({\n\t\t\tcategory: \"generic\",\n\t\t\teventName: \"fluid:telemetry:Test_start\",\n\t\t\ttestName: currentTestName,\n\t\t\ttestVariant,\n\t\t\thostName: pkgName,\n\t\t});\n\t},\n\tafterEach(this: Mocha.Context) {\n\t\t// send event on test end\n\t\toriginalLogger.send({\n\t\t\tcategory: \"generic\",\n\t\t\teventName: \"fluid:telemetry:Test_end\",\n\t\t\ttestName: currentTestName,\n\t\t\tstate: this.currentTest?.state,\n\t\t\tduration: this.currentTest?.duration,\n\t\t\ttimedOut: this.currentTest?.timedOut,\n\t\t\ttestVariant,\n\t\t\thostName: pkgName,\n\t\t\terror: this.currentTest?.err?.message,\n\t\t\tstack: this.currentTest?.err?.stack,\n\t\t});\n\n\t\tconsole.log = log;\n\t\tconsole.error = error;\n\t\tconsole.warn = warn;\n\n\t\t// clear the test logger and test name after each test\n\t\tcurrentTestLogger = undefined;\n\t\tcurrentTestName = undefined;\n\t},\n};\n\nglobalThis.getMochaModule = () => {\n\treturn mochaModule;\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.4.0";
8
+ export declare const pkgVersion = "2.5.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -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.4.0";
8
+ export const pkgVersion = "2.5.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,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 = \"2.4.0\";\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,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 = \"2.5.0\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-internal/mocha-test-setup",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Utilities for Fluid tests",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -30,17 +30,17 @@
30
30
  "main": "dist/index.js",
31
31
  "types": "dist/index.d.ts",
32
32
  "dependencies": {
33
- "@fluid-internal/test-driver-definitions": "~2.4.0",
34
- "@fluidframework/core-interfaces": "~2.4.0",
33
+ "@fluid-internal/test-driver-definitions": "~2.5.0",
34
+ "@fluidframework/core-interfaces": "~2.5.0",
35
35
  "mocha": "^10.2.0",
36
36
  "source-map-support": "^0.5.21"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@arethetypeswrong/cli": "^0.16.4",
40
- "@biomejs/biome": "~1.8.3",
41
- "@fluid-tools/build-cli": "^0.48.0",
40
+ "@biomejs/biome": "~1.9.3",
41
+ "@fluid-tools/build-cli": "^0.49.0",
42
42
  "@fluidframework/build-common": "^2.0.3",
43
- "@fluidframework/build-tools": "^0.48.0",
43
+ "@fluidframework/build-tools": "^0.49.0",
44
44
  "@fluidframework/eslint-config-fluid": "^5.4.0",
45
45
  "@microsoft/api-extractor": "7.47.8",
46
46
  "@types/mocha": "^9.1.1",
package/src/mochaHooks.ts CHANGED
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ITelemetryBufferedLogger } from "@fluid-internal/test-driver-definitions";
7
- import { ITelemetryBaseEvent } from "@fluidframework/core-interfaces";
6
+ import type { ITelemetryBufferedLogger } from "@fluid-internal/test-driver-definitions";
7
+ import type { ITelemetryBaseEvent } from "@fluidframework/core-interfaces";
8
8
  import * as mochaModule from "mocha";
9
9
 
10
10
  import { pkgName } from "./packageVersion.js";
@@ -15,7 +15,7 @@ import { pkgName } from "./packageVersion.js";
15
15
  // as this will incur a perf impact when errors are
16
16
  // thrown and will take more storage in any logging sink
17
17
  // https://v8.dev/docs/stack-trace-api
18
- Error.stackTraceLimit = Infinity;
18
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
19
19
 
20
20
  const testVariant = process.env.FLUID_TEST_VARIANT;
21
21
  const propsDict =
@@ -37,7 +37,13 @@ class TestLogger implements ITelemetryBufferedLogger {
37
37
  event.testName = this.testName ?? currentTestName;
38
38
  event.testVariant = testVariant;
39
39
  event.hostName = pkgName;
40
- this.parentLogger.send({ ...event, ...propsDict });
40
+ this.parentLogger.send({
41
+ ...event,
42
+ // If there's an override for the hostName in FLUID_LOGGER_PROPS,
43
+ // display that in the telemetry instead of the package name.
44
+ hostName: propsDict?.hostName ?? pkgName,
45
+ details: JSON.stringify(propsDict),
46
+ });
41
47
  }
42
48
  async flush() {
43
49
  return this.parentLogger.flush();
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluid-internal/mocha-test-setup";
9
- export const pkgVersion = "2.4.0";
9
+ export const pkgVersion = "2.5.0";