@fluid-internal/mocha-test-setup 2.60.0 → 2.61.0-355054

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/README.md CHANGED
@@ -40,8 +40,7 @@ Then put this in a `.mocharc.cjs` file at the root of your package:
40
40
 
41
41
  const getFluidTestMochaConfig = require("@fluid-internal/mocha-test-setup/mocharc-common");
42
42
 
43
- const packageDir = __dirname;
44
- const config = getFluidTestMochaConfig(packageDir);
43
+ const config = getFluidTestMochaConfig(__dirname);
45
44
  module.exports = config;
46
45
  ```
47
46
 
@@ -53,13 +52,24 @@ The default configuration generated by `getFluidTestMochaConfig()` looks like th
53
52
 
54
53
  ```jsonc
55
54
  {
56
- "exit": true,
57
55
  "recursive": true,
58
- "require": ["path1", "path2"], // Mapped paths for packages/modules indicated as required when calling getFluidTestMochaConfig()
56
+ "require": ["@fluid-internal/mocha-test-setup", "source-map-support/register"], // can be extended by providing additionalRequiredModules to getFluidTestMochaConfig()
59
57
  "unhandled-rejections": "strict",
58
+ "node-option": ["conditions=allow-ff-test-exports", "expose-gc"],
59
+ "ignore": [ "**/*.tool.{js,cjs,mjs}" ], // Ignore "tools" which are scripts intended to be run, not part of the test suite.
60
+ "spec": "lib/test" // Defaults to "lib/test" where esm tests typically are. Can be overridden via MOCHA_SPEC.
60
61
  };
61
62
  ```
62
63
 
64
+ It is recommended that the source for tests files use a file name ending in ".spec.ts", but this is not enforced:
65
+ no file named based filtering of test files is done by default, except for the ignoring of `"**/*.tool.{js,cjs,mjs}"` noted above.
66
+
67
+ Note: some packages do explicitly filter test files to `*.spec.js`: in such packages test files with other names will be silently ignored.
68
+
69
+ ## Environment Variables
70
+
71
+ In package.json scripts, environment variables can be set using cross-env, like "cross-env MOCHA_SPEC=lib/mocha/test mocha".
72
+
63
73
  The configuration will have additional settings if the following environment variables are present:
64
74
 
65
75
  ### FLUID_TEST_TIMEOUT
@@ -91,6 +101,20 @@ that to override them during execution time:
91
101
  FLUID_LOGGER_PROPS='{ "hostName": "Benchmark" }'
92
102
  ```
93
103
 
104
+ ### FLUID_TEST_LOGGER_PKG_SPECIFIER
105
+
106
+ Injects implementation of `createTestLogger`.
107
+ We use it in our pipelines to submit telemetry to internal engineering systems.
108
+ Probably not useful outside of that scenario, except when using it locally to test something related to its use in the pipelines.
109
+
110
+ ### MOCHA_SPEC
111
+
112
+ Select the "spec".
113
+ Note that unlike Mocha's built in MOCHA_OPTIONS environment variable,
114
+ this will replace our default spec instead of adding to the spec (See https://mochajs.org/next/running/configuring/#merging).
115
+ Also unlike Mocha's default behavior (see https://mochajs.org/next/running/cli/),
116
+ this configuration defaults spec to `lib/test` (where we place our esm tests) instead of `test`.
117
+
94
118
  ## Mapping of package paths to account for Lerna hoisting
95
119
 
96
120
  The way we use Lerna to manage our monorepo, package dependencies are sometimes moved out of the `node_modules` folder
@@ -128,7 +152,7 @@ might behave differently locally and in CI builds, so that's another factor to k
128
152
 
129
153
  ## Special behavior
130
154
 
131
- ### Supress console output by default
155
+ ### Suppress console output by default
132
156
 
133
157
  `console.log()`, `console.warn()` and `console.error()` are disabled by default when using this package.
134
158
  They can be re-enabled by setting the `FLUID_TEST_VERBOSE` environment variable to any non-empty value, e.g.
@@ -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.60.0";
8
+ export declare const pkgVersion = "2.61.0-355054";
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,WAAW,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,kBAAkB,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.60.0";
11
+ exports.pkgVersion = "2.61.0-355054";
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,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.60.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,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.61.0-355054\";\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.60.0";
8
+ export declare const pkgVersion = "2.61.0-355054";
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,WAAW,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,kBAAkB,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.60.0";
8
+ export const pkgVersion = "2.61.0-355054";
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,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.60.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,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.61.0-355054\";\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.8"
8
+ "packageVersion": "7.52.11"
9
9
  }
10
10
  ]
11
11
  }
@@ -8,6 +8,17 @@
8
8
  const { existsSync } = require("fs");
9
9
  const path = require("path");
10
10
 
11
+ /**
12
+ * Get the mocha configuration for running tests using the conventions followed in the Fluid Framework repository.
13
+ *
14
+ * @param {string} packageDir - the directory of the package, typically set using `__dirname`
15
+ * @param {string[]} additionalRequiredModules - modules to require in addition to the standard set.
16
+ * @param {string} testReportPrefix - prefix for the test output report file names.
17
+ * @remarks
18
+ * Additional configuration can be provided via environment variables: see {@link file://./README.md}.
19
+ *
20
+ * Users desiring exact control over the `spec` from the CLI should delete or replace the spec from the returned config, since mocha's behavior is to extend it, not override it.
21
+ */
11
22
  function getFluidTestMochaConfig(packageDir, additionalRequiredModules, testReportPrefix) {
12
23
  const moduleDir = `${packageDir}/node_modules`;
13
24
 
@@ -53,6 +64,10 @@ function getFluidTestMochaConfig(packageDir, additionalRequiredModules, testRepo
53
64
  "recursive": true,
54
65
  "require": requiredModulePaths,
55
66
  "unhandled-rejections": "strict",
67
+ ignore: [
68
+ // Ignore "tools" which are scripts intended to be run, not part of the test suite.
69
+ "**/*.tool.{js,cjs,mjs}",
70
+ ],
56
71
  "node-option": [
57
72
  // Allow test-only indexes to be imported. Search the FF repo for package.json files with this condition to see example usage.
58
73
  "conditions=allow-ff-test-exports",
@@ -62,6 +77,7 @@ function getFluidTestMochaConfig(packageDir, additionalRequiredModules, testRepo
62
77
  // these must be provided here and not via mocha's --v8-expose-gc.
63
78
  "expose-gc",
64
79
  ],
80
+ spec: process.env.MOCHA_SPEC ?? "lib/test",
65
81
  };
66
82
 
67
83
  if (process.env.FLUID_TEST_TIMEOUT !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-internal/mocha-test-setup",
3
- "version": "2.60.0",
3
+ "version": "2.61.0-355054",
4
4
  "description": "Utilities for Fluid tests",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -30,19 +30,19 @@
30
30
  "main": "dist/index.js",
31
31
  "types": "dist/index.d.ts",
32
32
  "dependencies": {
33
- "@fluid-internal/test-driver-definitions": "~2.60.0",
34
- "@fluidframework/core-interfaces": "~2.60.0",
33
+ "@fluid-internal/test-driver-definitions": "2.61.0-355054",
34
+ "@fluidframework/core-interfaces": "2.61.0-355054",
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.57.0",
41
+ "@fluid-tools/build-cli": "^0.58.2",
42
42
  "@fluidframework/build-common": "^2.0.3",
43
- "@fluidframework/build-tools": "^0.57.0",
43
+ "@fluidframework/build-tools": "^0.58.2",
44
44
  "@fluidframework/eslint-config-fluid": "^6.0.0",
45
- "@microsoft/api-extractor": "7.52.8",
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",
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluid-internal/mocha-test-setup";
9
- export const pkgVersion = "2.60.0";
9
+ export const pkgVersion = "2.61.0-355054";