@fluid-internal/mocha-test-setup 3.4.0 → 3.6.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 +8 -0
- package/README.md +65 -111
- package/lib/mocharcCommon.d.ts +4 -2
- package/lib/mocharcCommon.d.ts.map +1 -1
- package/lib/mocharcCommon.js +15 -2
- package/lib/mocharcCommon.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +5 -5
- package/src/mocharcCommon.ts +15 -2
- package/src/packageVersion.ts +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -15,10 +15,72 @@ This package has a few main purposes:
|
|
|
15
15
|
|
|
16
16
|
- Expose/generate a default `.mocharc.cjs` configuration for running [mocha](https://mochajs.org) tests, which other
|
|
17
17
|
packages can extend.
|
|
18
|
-
- Map paths for required packages/modules to account for [Lerna](https://lerna.js.org/)'s dependency hoisting.
|
|
19
18
|
- Add mocha `beforeAll`, `beforeEach` and `afterEach` [root hook plugins](https://mochajs.org/#root-hook-plugins) to add
|
|
20
19
|
some special behavior when we run tests.
|
|
21
20
|
|
|
21
|
+
## Running tests
|
|
22
|
+
|
|
23
|
+
For packages using this configuration, build the package and its tests, then run `pnpm exec mocha` from the package directory.
|
|
24
|
+
|
|
25
|
+
- [Select test files with `MOCHA_SPEC`](#mocha_spec).
|
|
26
|
+
- [Filter test names with Mocha's `--fgrep` or `--grep`](https://mochajs.org/running/cli/#--fgrep-string--f-string).
|
|
27
|
+
- [Enable performance measurements with `FLUID_TEST_PERF_MODE`](#fluid_test_perf_mode).
|
|
28
|
+
|
|
29
|
+
## Environment Variables
|
|
30
|
+
|
|
31
|
+
Set environment variables before running Mocha.
|
|
32
|
+
For cross-platform scripts, use `cross-env`, for example `pnpm exec cross-env MOCHA_SPEC=lib/test/example.spec.js mocha`.
|
|
33
|
+
|
|
34
|
+
### MOCHA_SPEC
|
|
35
|
+
|
|
36
|
+
Sets the compiled test file, directory, or glob to load, relative to the package directory.
|
|
37
|
+
It replaces the default selection of `lib/test` (or `dist/test` with [`FLUID_TEST_MODULE_SYSTEM=CJS`](#fluid_test_module_system)).
|
|
38
|
+
Unlike `MOCHA_SPEC`, positional file arguments and `--spec` add to the configured selection because of [Mocha's configuration merging](https://mochajs.org/next/running/configuring/#merging).
|
|
39
|
+
Name filtering alone still loads all configured test files; use `MOCHA_SPEC` to avoid loading unrelated files.
|
|
40
|
+
|
|
41
|
+
### FLUID_TEST_PERF_MODE
|
|
42
|
+
|
|
43
|
+
Set to `1` to measure benchmarks instead of running them as correctness tests.
|
|
44
|
+
Leave unset for correctness testing; do not use `0` to disable it.
|
|
45
|
+
|
|
46
|
+
This selects the benchmark reporter, sets a 1,000-second timeout per test, and writes results to `./benchmarkOutput.json`.
|
|
47
|
+
Override the timeout with [`FLUID_TEST_TIMEOUT`](#fluid_test_timeout) and the report path with `--reporterOptions reportFile=<path>`.
|
|
48
|
+
|
|
49
|
+
The default `@Benchmark` filter is omitted when you supply `--fgrep <text>` or `--grep <pattern>` (use these long options with separate arguments).
|
|
50
|
+
Your filter replaces, rather than intersects with, the default.
|
|
51
|
+
See [benchmark filtering](../../../tools/benchmark/README.md#--fgrep-benchmark) for tags and combining constraints.
|
|
52
|
+
|
|
53
|
+
### FLUID_TEST_TIMEOUT
|
|
54
|
+
|
|
55
|
+
Overrides Mocha's per-test timeout in milliseconds, including the performance-mode default.
|
|
56
|
+
|
|
57
|
+
### FLUID_TEST_FORBID_ONLY
|
|
58
|
+
|
|
59
|
+
When present, enables Mocha's `forbid-only` option to reject exclusive tests.
|
|
60
|
+
|
|
61
|
+
### FLUID_TEST_MODULE_SYSTEM
|
|
62
|
+
|
|
63
|
+
When set to "CJS", current run is setup to be for CommonJS coverage:
|
|
64
|
+
- "CJS" is noted as a variant and shown as prefix to test case names.
|
|
65
|
+
- The JUnit test-results file will be prefixed with "CJS-".
|
|
66
|
+
- Default spec is changed from `lib/test` to `dist/test`.
|
|
67
|
+
|
|
68
|
+
### FLUID_LOGGER_PROPS
|
|
69
|
+
|
|
70
|
+
Sets a JSON object serialized into the `testEnvProps` telemetry field.
|
|
71
|
+
Its `hostName` property also overrides the event's `hostName`:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
FLUID_LOGGER_PROPS='{ "hostName": "Benchmark" }'
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### FLUID_TEST_LOGGER_PKG_SPECIFIER
|
|
78
|
+
|
|
79
|
+
Specifies a module exporting `createTestLogger`, which returns an `ITelemetryBufferedLogger`.
|
|
80
|
+
The setup calls this factory, wraps the logger with test context, and installs the global `getTestLogger` function.
|
|
81
|
+
Use this variable rather than `--require` to configure a custom logger.
|
|
82
|
+
Pipelines use it to send telemetry to internal engineering systems.
|
|
83
|
+
|
|
22
84
|
## Base `mocharc.cjs` configuration
|
|
23
85
|
|
|
24
86
|
To leverage the base mocha configuration exposed by this package, first add it as a `devDependency` to your `package.json`
|
|
@@ -47,7 +109,7 @@ If you need extra configuration, make changes to the `config` object before assi
|
|
|
47
109
|
|
|
48
110
|
Mocha will use this file by default if no path to a configuration file is provided explicitly.
|
|
49
111
|
|
|
50
|
-
The
|
|
112
|
+
The following excerpt shows some of the settings generated by `getFluidTestMochaConfig()`:
|
|
51
113
|
|
|
52
114
|
```jsonc
|
|
53
115
|
{
|
|
@@ -65,104 +127,11 @@ no file named based filtering of test files is done by default, except for the i
|
|
|
65
127
|
|
|
66
128
|
Note: some packages do explicitly filter test files to `*.spec.js`: in such packages test files with other names will be silently ignored.
|
|
67
129
|
|
|
68
|
-
## Environment Variables
|
|
69
|
-
|
|
70
|
-
In package.json scripts, environment variables can be set using cross-env, like "cross-env MOCHA_SPEC=lib/mocha/test/**/*.spec.*js mocha".
|
|
71
|
-
|
|
72
|
-
The configuration will have additional settings if the following environment variables are present:
|
|
73
|
-
|
|
74
|
-
### FLUID_TEST_TIMEOUT
|
|
75
|
-
|
|
76
|
-
If it exists, the default configuration will also include this:
|
|
77
|
-
|
|
78
|
-
```json
|
|
79
|
-
{
|
|
80
|
-
"timeout": "<value-of-FLUID_TEST_TIMEOUT>"
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### FLUID_TEST_FORBID_ONLY
|
|
85
|
-
|
|
86
|
-
If it exists, the default configuration will also include this:
|
|
87
|
-
|
|
88
|
-
```json
|
|
89
|
-
{
|
|
90
|
-
"forbid-only": "true"
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### FLUID_LOGGER_PROPS
|
|
95
|
-
|
|
96
|
-
In case there is a need to override telemetry metrics, one can make use of an environment variable `FLUID_LOGGER_PROPS`,
|
|
97
|
-
that to override them during execution time:
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
FLUID_LOGGER_PROPS='{ "hostName": "Benchmark" }'
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### FLUID_TEST_LOGGER_PKG_SPECIFIER
|
|
104
|
-
|
|
105
|
-
Injects implementation of `createTestLogger`.
|
|
106
|
-
We use it in our pipelines to submit telemetry to internal engineering systems.
|
|
107
|
-
Probably not useful outside of that scenario, except when using it locally to test something related to its use in the pipelines.
|
|
108
|
-
|
|
109
|
-
### FLUID_TEST_MODULE_SYSTEM
|
|
110
|
-
|
|
111
|
-
When set to "CJS", current run is setup to be for CommonJS coverage:
|
|
112
|
-
- "CJS" is noted as a variant and shown as prefix to test case names.
|
|
113
|
-
- Coverage file will be prefixed with "CJS-".
|
|
114
|
-
- Default spec is changed from `lib/test` to `dist/test`; see more below.
|
|
115
|
-
|
|
116
|
-
### MOCHA_SPEC
|
|
117
|
-
|
|
118
|
-
Select the "spec".
|
|
119
|
-
Note that unlike Mocha's built in MOCHA_OPTIONS environment variable,
|
|
120
|
-
this will replace our default spec instead of adding to the spec (See https://mochajs.org/next/running/configuring/#merging).
|
|
121
|
-
Also unlike Mocha's default behavior (see https://mochajs.org/next/running/cli/),
|
|
122
|
-
this configuration defaults spec to `lib/test` (where we place our esm tests) instead of `test`.
|
|
123
|
-
|
|
124
|
-
## Mapping of package paths to account for Lerna hoisting
|
|
125
|
-
|
|
126
|
-
The way we use Lerna to manage our monorepo, package dependencies are sometimes moved out of the `node_modules` folder
|
|
127
|
-
of the package that declares them, and into a `node_modules` folder at the root of the release group.
|
|
128
|
-
This applies to external dependencies (i.e. not between packages in our repo) that are present in more than one of our
|
|
129
|
-
packages, including `mocha` itself as well as other test runners, which means that their path when they execute
|
|
130
|
-
might not be the one you'd normally expect.
|
|
131
|
-
This can cause issues when test scripts point to other dependencies of the package being tested (e.g. with the `-r/--require`
|
|
132
|
-
flag) when running tests.
|
|
133
|
-
This utility maps the paths of packages/modules passed to the `getFluidTestMochaConfig()` function, to ensure they are
|
|
134
|
-
imported from whichever location they end up at.
|
|
135
|
-
|
|
136
|
-
**NOTE**: once we move to `pnpm` this functionality might become irrelevant because `pnpm` keeps all dependencies in the
|
|
137
|
-
expected paths and creates the necessary symlinks, instead of changing where dependency folders are located.
|
|
138
|
-
|
|
139
|
-
### Considerations for non-package/module arguments
|
|
140
|
-
|
|
141
|
-
Sometimes you'll want to provide a package/module/path as an argument when executing your tests but outside of the
|
|
142
|
-
required packages that you can pass to `getFluidTestMochaConfig()`.
|
|
143
|
-
For example, the path to a reporter file:
|
|
144
|
-
|
|
145
|
-
```console
|
|
146
|
-
mocha --require @fluid-internal/mocha-test-setup --reporter @fluid-tools/benchmark/dist/mocha/Reporter.js
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
Depending on where that file is coming from, you'll need to be careful with how that path is specified.
|
|
150
|
-
E.g. `@fluid-tools/benchmark`, while being part of the repository, is not part of any release group, so it will always
|
|
151
|
-
be downloaded from the public npm feed and treated as an external dependency.
|
|
152
|
-
Since several packages declare it as a dependency, Lerna will hoist it to `node_modules` at the root of the release group.
|
|
153
|
-
In general, the safest solution is to specify it starting with the package name (including scope if applicable).
|
|
154
|
-
This might break in a few edge cases as long as we use Lerna with hoisting, so we'll have to deal with them individually.
|
|
155
|
-
|
|
156
|
-
A particular way of specifying a package/module/path (e.g. starting with the package name vs starting with `node_modules/`)
|
|
157
|
-
might behave differently locally and in CI builds, so that's another factor to keep in mind.
|
|
158
|
-
|
|
159
130
|
## Special behavior
|
|
160
131
|
|
|
161
132
|
### Suppress console output by default
|
|
162
133
|
|
|
163
|
-
`console.log()`, `console.warn()` and `console.error()` are
|
|
164
|
-
They can be re-enabled by setting the `FLUID_TEST_VERBOSE` environment variable to any non-empty value, e.g.
|
|
165
|
-
`FLUID_TEST_VERBOSE=1`.
|
|
134
|
+
`console.log()`, `console.warn()` and `console.error()` are suppressed during tests unless `FLUID_TEST_VERBOSE` is set, for example `FLUID_TEST_VERBOSE=1`.
|
|
166
135
|
|
|
167
136
|
### Telemetry events
|
|
168
137
|
|
|
@@ -170,21 +139,6 @@ A couple of telemetry events `fluid:telemetry:Test_start` and `fluid:telemetry:T
|
|
|
170
139
|
The `Test_end` event includes fields with the test's state (passing/failed), its duration, if it timed out.
|
|
171
140
|
If a `FLUID_TEST_VARIANT` environment variable exists, the `testVariant` field in the events will have its value.
|
|
172
141
|
|
|
173
|
-
### Support for a custom logger
|
|
174
|
-
|
|
175
|
-
This utility supports using a custom logger implementation.
|
|
176
|
-
This can be useful to send the operational telemetry generated by the FluidFramework while the tests are running, to a
|
|
177
|
-
particular log sink.
|
|
178
|
-
|
|
179
|
-
It is expected that the package with the custom logger implementation adds a `getTestLogger() => ITelemetryBufferedLogger`
|
|
180
|
-
function to the `global` object, which this package will call in order to obtain an instance of the custom logger.
|
|
181
|
-
|
|
182
|
-
If a custom logger implementation will be used when executing tests in a package that leverages this utility, the path
|
|
183
|
-
to the module with that implementation should **not** be specified with the `--require/-r` flag, but through the
|
|
184
|
-
`FLUID_TEST_LOGGER_PKG_PATH` environment variable.
|
|
185
|
-
This package has logic that needs the custom logger to be imported/executed at a particular time, and we ensure that
|
|
186
|
-
by requiring that the path be provided through that environment variable.
|
|
187
|
-
|
|
188
142
|
<!-- markdown-magic:begin {"transform":"readme-footer","headingLevel":2} -->
|
|
189
143
|
<!-- prettier-ignore-start -->
|
|
190
144
|
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
package/lib/mocharcCommon.d.ts
CHANGED
|
@@ -28,9 +28,11 @@ export interface FluidTestMochaConfig {
|
|
|
28
28
|
* @param additionalRequiredModules - modules to require in addition to the standard set.
|
|
29
29
|
* @param testReportPrefix - prefix for the test output report file names.
|
|
30
30
|
* @remarks
|
|
31
|
-
*
|
|
31
|
+
* See the "Running tests" section in [README.md](../README.md)
|
|
32
|
+
* for test selection, performance measurements, and environment variable configuration.
|
|
32
33
|
*
|
|
33
|
-
*
|
|
34
|
+
* Mocha’s CLI `spec` arguments add to the configured selection rather than replacing it.
|
|
35
|
+
* For exact control over `spec` (including via the CLI), replace or delete the `spec` property in the returned configuration.
|
|
34
36
|
*/
|
|
35
37
|
export declare function getFluidTestMochaConfig(packageDir: string, additionalRequiredModules?: string[], testReportPrefix?: string): FluidTestMochaConfig;
|
|
36
38
|
//# sourceMappingURL=mocharcCommon.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocharcCommon.d.ts","sourceRoot":"","sources":["../src/mocharcCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"mocharcCommon.d.ts","sourceRoot":"","sources":["../src/mocharcCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAYD;;;;;;;;;;;;GAYG;AAEH,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,MAAM,EAClB,yBAAyB,CAAC,EAAE,MAAM,EAAE,EACpC,gBAAgB,CAAC,EAAE,MAAM,GACvB,oBAAoB,CAgHtB"}
|
package/lib/mocharcCommon.js
CHANGED
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
|
+
/* eslint-disable @fluid-internal/fluid/no-markdown-links-in-jsdoc --
|
|
8
|
+
This configuration helper is not published in API docs so we can keep its README link source-relative.
|
|
9
|
+
Sadly there seems to be no way to link the readme file with {@link} tags nor raw file urls that can actually be clicked in VS-Code
|
|
10
|
+
(directly or via intellisense) without giving errors due to needing to navigate up via `..` which is blocked.
|
|
11
|
+
There also seems to be no way to make this link go to the relevant anchor in the README file as vscode interprets it as part of the file name,
|
|
12
|
+
rather than recognizing it as an anchor within the file.
|
|
13
|
+
I still think using this non anchored markdown link is better than linking to a URL on github which points either to this branch,
|
|
14
|
+
or main where these docs don't even exist yet.
|
|
15
|
+
Thus I feel this lint suppression allows for a better link, and thus is justified.
|
|
16
|
+
*/
|
|
7
17
|
/**
|
|
8
18
|
* Get the mocha configuration for running tests using the conventions followed in the Fluid Framework repository.
|
|
9
19
|
*
|
|
@@ -11,10 +21,13 @@ import path from "node:path";
|
|
|
11
21
|
* @param additionalRequiredModules - modules to require in addition to the standard set.
|
|
12
22
|
* @param testReportPrefix - prefix for the test output report file names.
|
|
13
23
|
* @remarks
|
|
14
|
-
*
|
|
24
|
+
* See the "Running tests" section in [README.md](../README.md)
|
|
25
|
+
* for test selection, performance measurements, and environment variable configuration.
|
|
15
26
|
*
|
|
16
|
-
*
|
|
27
|
+
* Mocha’s CLI `spec` arguments add to the configured selection rather than replacing it.
|
|
28
|
+
* For exact control over `spec` (including via the CLI), replace or delete the `spec` property in the returned configuration.
|
|
17
29
|
*/
|
|
30
|
+
/* eslint-enable @fluid-internal/fluid/no-markdown-links-in-jsdoc -- see the disable for details */
|
|
18
31
|
export function getFluidTestMochaConfig(packageDir, additionalRequiredModules, testReportPrefix) {
|
|
19
32
|
const requiredModules = [
|
|
20
33
|
// General mocha setup e.g. suppresses console.log,
|
package/lib/mocharcCommon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocharcCommon.js","sourceRoot":"","sources":["../src/mocharcCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,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,CAAC,GAAG,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9E,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;YAClD,OAAO,CAAC,GAAG,CACV,mDAAmD,gBAAgB,kBAAkB,CACrF,CAAC;QACH,CAAC;QACD,MAAM,SAAS,GACd,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,IAAI,MAAM,YAAY,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;QACzF,yGAAyG;QACzG,yGAAyG;QACzG,uGAAuG;QACvG,qGAAqG;QACrG,4FAA4F;QAC5F,MAAM,iBAAiB,GAAG,iDAAiD,CAAC;QAC5E,MAAM,CAAC,kBAAkB,CAAC,GAAG;YAC5B,cAAc,IAAI,CAAC,IAAI,CACtB,MAAM,CAAC,IAAI,CAAC,OAAO,EACnB,IAAI,EACJ,kBAAkB,CAClB,cAAc,iBAAiB,WAAW,gBAAgB,IAAI,iBAAiB,cAAc,SAAS,EAAE;SACzG,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;QAClD,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IACjD,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB,KAAK,SAAS,EAAE,CAAC;QACtD,MAAM,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;IAC9B,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * Mocha configuration object returned by {@link getFluidTestMochaConfig}.\n */\nexport interface FluidTestMochaConfig {\n\trecursive: boolean;\n\trequire: string[];\n\t\"unhandled-rejections\": string;\n\t\"fail-zero\": boolean;\n\tignore: string[];\n\t\"node-option\": string[];\n\tspec: string;\n\texit?: boolean;\n\ttimeout?: number | string;\n\tfgrep?: string[];\n\treporter?: string;\n\treporterOptions?: string[];\n\t\"reporter-options\"?: string[];\n\t\"forbid-only\"?: boolean;\n}\n\n/**\n * Get the mocha configuration for running tests using the conventions followed in the Fluid Framework repository.\n *\n * @param packageDir - the directory of the package, typically set using `__dirname`\n * @param additionalRequiredModules - modules to require in addition to the standard set.\n * @param testReportPrefix - prefix for the test output report file names.\n * @remarks\n * Additional configuration can be provided via environment variables: see {@link file://./README.md}.\n *\n * 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.\n */\nexport function getFluidTestMochaConfig(\n\tpackageDir: string,\n\tadditionalRequiredModules?: string[],\n\ttestReportPrefix?: string,\n): FluidTestMochaConfig {\n\tconst requiredModules = [\n\t\t// General mocha setup e.g. suppresses console.log,\n\t\t// This has to be before others (except logger) so that registerMochaTestWrapperFuncs is available\n\t\t\"@fluid-internal/mocha-test-setup\",\n\t\t\"source-map-support/register\",\n\t\t...(additionalRequiredModules ?? []),\n\t];\n\n\tif (process.env.FLUID_TEST_LOGGER_PKG_SPECIFIER !== undefined) {\n\t\t// Inject implementation of createTestLogger, put it first before mocha-test-setup\n\t\trequiredModules.unshift(process.env.FLUID_TEST_LOGGER_PKG_SPECIFIER);\n\t}\n\n\tlet reportPrefix = testReportPrefix;\n\tlet defaultSpec = \"lib/test\";\n\tif (process.env.FLUID_TEST_MODULE_SYSTEM === \"CJS\") {\n\t\tdefaultSpec = \"dist/test\";\n\t\tconst testVariant = process.env.FLUID_TEST_VARIANT;\n\t\tprocess.env.FLUID_TEST_VARIANT = testVariant !== undefined ? `CJS,${testVariant}` : \"CJS\";\n\t\treportPrefix = reportPrefix !== undefined ? `${reportPrefix}-CJS` : \"CJS\";\n\t}\n\n\tconst config: FluidTestMochaConfig = {\n\t\t\"recursive\": true,\n\t\t\"require\": requiredModules,\n\t\t\"unhandled-rejections\": \"strict\",\n\t\t// Fail the test run if no tests are found/run. This catches cases where test files fail to\n\t\t// load silently (e.g. due to broken imports), which would otherwise produce a green \"0 passing\"\n\t\t// result with exit code 0.\n\t\t\"fail-zero\": true,\n\t\tignore: [\n\t\t\t// Ignore \"tools\" which are scripts intended to be run, not part of the test suite.\n\t\t\t\"**/*.tool.{js,cjs,mjs}\",\n\t\t],\n\t\t\"node-option\": [\n\t\t\t// Allow test-only indexes to be imported. Search the FF repo for package.json files with this condition to see example usage.\n\t\t\t\"conditions=allow-ff-test-exports\",\n\t\t\t// Performance tests benefit from having access to GC, and memory tests require it.\n\t\t\t// Exposing it here avoids all packages which do perf testing from having to expose it.\n\t\t\t// Note that since \"node-option\" is explicitly set,\n\t\t\t// these must be provided here and not via mocha's --v8-expose-gc.\n\t\t\t\"expose-gc\",\n\t\t],\n\t\tspec: process.env.MOCHA_SPEC ?? defaultSpec,\n\t};\n\n\t// This approach to checking for this flag is consistent with some (but not all) others in this file,\n\t// but not with tools/benchmark/src/Configuration.ts.\n\t// For now, undefined, \"1\" and \"true\" should work consistently across all known use, and \"1\" is the main form we explicitly use.\n\t// All these should be made to match, see AB#69054.\n\tif (process.env.FLUID_TEST_PERF_MODE !== undefined) {\n\t\tif (process.env.SILENT_TEST_OUTPUT === undefined) {\n\t\t\tconsole.log(`Running performance tests...`);\n\t\t}\n\n\t\t// Some perf tests are often quite slow, and we don't want to lose the data by hitting a timeout.\n\t\t// This is 1000 seconds, so ~16 minutes.\n\t\t// This can be overridden by setting FLUID_TEST_TIMEOUT to a different value if desired.\n\t\tconfig.timeout = 1_000_000;\n\n\t\t// If there is no filter specified, limit to benchmarks.\n\t\t// If mocha allowed multiple filters to all be applied to further narrow results, we would do this unconditionally.\n\t\tif (!(process.argv.includes(\"--fgrep\") || process.argv.includes(\"--grep\"))) {\n\t\t\tconfig.fgrep = [\"@Benchmark\"];\n\t\t}\n\n\t\tconfig.reporter = \"@fluid-tools/benchmark/dist/mocha/Reporter.js\";\n\t\tif (!process.argv.includes(\"--reporterOptions\")) {\n\t\t\t// If report options were not specified, default to:\n\t\t\tconfig.reporterOptions = [\"reportFile=./benchmarkOutput.json\"];\n\t\t}\n\t} else {\n\t\tconst packageJsonPath = path.join(packageDir, \"package.json\");\n\t\tconst packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as {\n\t\t\tname: string;\n\t\t};\n\t\tconfig.reporter = `mocha-multi-reporters`;\n\t\t// See https://www.npmjs.com/package/mocha-multi-reporters#cmroutput-option\n\n\t\tconst outputFilePrefix = reportPrefix !== undefined ? `${reportPrefix}-` : \"\";\n\t\tif (process.env.SILENT_TEST_OUTPUT === undefined) {\n\t\t\tconsole.log(\n\t\t\t\t`Writing test results relative to package to nyc/${outputFilePrefix}junit-report.xml`,\n\t\t\t);\n\t\t}\n\t\tconst suiteName =\n\t\t\treportPrefix !== undefined ? `${packageJson.name} - ${reportPrefix}` : packageJson.name;\n\t\t// This must be the exact module specifier mocha-multi-reporters will `require(...)` to load the reporter\n\t\t// (see its source: https://github.com/stevemao/mocha-multi-reporters/blob/master/lib/MultiReporters.js),\n\t\t// i.e. it can't be shortened to some arbitrary friendly name. It also determines the reporter-specific\n\t\t// option key mocha-multi-reporters expects below (and in test-config.json): it camelCases this exact\n\t\t// string and appends \"ReporterOptions\" (e.g. \"@foo/bar/baz\" -> \"fooBarBazReporterOptions\").\n\t\tconst xunitReporterName = \"@fluid-internal/mocha-test-setup/xunit-reporter\";\n\t\tconfig[\"reporter-options\"] = [\n\t\t\t`configFile=${path.join(\n\t\t\t\timport.meta.dirname,\n\t\t\t\t\"..\",\n\t\t\t\t\"test-config.json\",\n\t\t\t)},cmrOutput=${xunitReporterName}+output+${outputFilePrefix}:${xunitReporterName}+suiteName+${suiteName}`,\n\t\t];\n\t}\n\n\tif (process.env.FLUID_TEST_TIMEOUT !== undefined) {\n\t\tconfig.timeout = process.env.FLUID_TEST_TIMEOUT;\n\t}\n\n\tif (process.env.FLUID_TEST_FORBID_ONLY !== undefined) {\n\t\tconfig[\"forbid-only\"] = true;\n\t}\n\n\treturn config;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mocharcCommon.js","sourceRoot":"","sources":["../src/mocharcCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAsB7B;;;;;;;;;EASE;AACF;;;;;;;;;;;;GAYG;AACH,mGAAmG;AACnG,MAAM,UAAU,uBAAuB,CACtC,UAAkB,EAClB,yBAAoC,EACpC,gBAAyB;IAEzB,MAAM,eAAe,GAAG;QACvB,mDAAmD;QACnD,kGAAkG;QAClG,kCAAkC;QAClC,6BAA6B;QAC7B,GAAG,CAAC,yBAAyB,IAAI,EAAE,CAAC;KACpC,CAAC;IAEF,IAAI,OAAO,CAAC,GAAG,CAAC,+BAA+B,KAAK,SAAS,EAAE,CAAC;QAC/D,kFAAkF;QAClF,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IACtE,CAAC;IAED,IAAI,YAAY,GAAG,gBAAgB,CAAC;IACpC,IAAI,WAAW,GAAG,UAAU,CAAC;IAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,KAAK,EAAE,CAAC;QACpD,WAAW,GAAG,WAAW,CAAC;QAC1B,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QAC1F,YAAY,GAAG,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,YAAY,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;IAC3E,CAAC;IAED,MAAM,MAAM,GAAyB;QACpC,WAAW,EAAE,I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AC;AACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * Mocha configuration object returned by {@link getFluidTestMochaConfig}.\n */\nexport interface FluidTestMochaConfig {\n\trecursive: boolean;\n\trequire: string[];\n\t\"unhandled-rejections\": string;\n\t\"fail-zero\": boolean;\n\tignore: string[];\n\t\"node-option\": string[];\n\tspec: string;\n\texit?: boolean;\n\ttimeout?: number | string;\n\tfgrep?: string[];\n\treporter?: string;\n\treporterOptions?: string[];\n\t\"reporter-options\"?: string[];\n\t\"forbid-only\"?: boolean;\n}\n\n/* eslint-disable @fluid-internal/fluid/no-markdown-links-in-jsdoc --\nThis configuration helper is not published in API docs so we can keep its README link source-relative.\nSadly there seems to be no way to link the readme file with {@link} tags nor raw file urls that can actually be clicked in VS-Code\n(directly or via intellisense) without giving errors due to needing to navigate up via `..` which is blocked.\nThere also seems to be no way to make this link go to the relevant anchor in the README file as vscode interprets it as part of the file name,\nrather than recognizing it as an anchor within the file.\nI still think using this non anchored markdown link is better than linking to a URL on github which points either to this branch,\nor main where these docs don't even exist yet.\nThus I feel this lint suppression allows for a better link, and thus is justified.\n*/\n/**\n * Get the mocha configuration for running tests using the conventions followed in the Fluid Framework repository.\n *\n * @param packageDir - the directory of the package, typically set using `__dirname`\n * @param additionalRequiredModules - modules to require in addition to the standard set.\n * @param testReportPrefix - prefix for the test output report file names.\n * @remarks\n * See the \"Running tests\" section in [README.md](../README.md)\n * for test selection, performance measurements, and environment variable configuration.\n *\n * Mocha’s CLI `spec` arguments add to the configured selection rather than replacing it.\n * For exact control over `spec` (including via the CLI), replace or delete the `spec` property in the returned configuration.\n */\n/* eslint-enable @fluid-internal/fluid/no-markdown-links-in-jsdoc -- see the disable for details */\nexport function getFluidTestMochaConfig(\n\tpackageDir: string,\n\tadditionalRequiredModules?: string[],\n\ttestReportPrefix?: string,\n): FluidTestMochaConfig {\n\tconst requiredModules = [\n\t\t// General mocha setup e.g. suppresses console.log,\n\t\t// This has to be before others (except logger) so that registerMochaTestWrapperFuncs is available\n\t\t\"@fluid-internal/mocha-test-setup\",\n\t\t\"source-map-support/register\",\n\t\t...(additionalRequiredModules ?? []),\n\t];\n\n\tif (process.env.FLUID_TEST_LOGGER_PKG_SPECIFIER !== undefined) {\n\t\t// Inject implementation of createTestLogger, put it first before mocha-test-setup\n\t\trequiredModules.unshift(process.env.FLUID_TEST_LOGGER_PKG_SPECIFIER);\n\t}\n\n\tlet reportPrefix = testReportPrefix;\n\tlet defaultSpec = \"lib/test\";\n\tif (process.env.FLUID_TEST_MODULE_SYSTEM === \"CJS\") {\n\t\tdefaultSpec = \"dist/test\";\n\t\tconst testVariant = process.env.FLUID_TEST_VARIANT;\n\t\tprocess.env.FLUID_TEST_VARIANT = testVariant !== undefined ? `CJS,${testVariant}` : \"CJS\";\n\t\treportPrefix = reportPrefix !== undefined ? `${reportPrefix}-CJS` : \"CJS\";\n\t}\n\n\tconst config: FluidTestMochaConfig = {\n\t\t\"recursive\": true,\n\t\t\"require\": requiredModules,\n\t\t\"unhandled-rejections\": \"strict\",\n\t\t// Fail the test run if no tests are found/run. This catches cases where test files fail to\n\t\t// load silently (e.g. due to broken imports), which would otherwise produce a green \"0 passing\"\n\t\t// result with exit code 0.\n\t\t\"fail-zero\": true,\n\t\tignore: [\n\t\t\t// Ignore \"tools\" which are scripts intended to be run, not part of the test suite.\n\t\t\t\"**/*.tool.{js,cjs,mjs}\",\n\t\t],\n\t\t\"node-option\": [\n\t\t\t// Allow test-only indexes to be imported. Search the FF repo for package.json files with this condition to see example usage.\n\t\t\t\"conditions=allow-ff-test-exports\",\n\t\t\t// Performance tests benefit from having access to GC, and memory tests require it.\n\t\t\t// Exposing it here avoids all packages which do perf testing from having to expose it.\n\t\t\t// Note that since \"node-option\" is explicitly set,\n\t\t\t// these must be provided here and not via mocha's --v8-expose-gc.\n\t\t\t\"expose-gc\",\n\t\t],\n\t\tspec: process.env.MOCHA_SPEC ?? defaultSpec,\n\t};\n\n\t// This approach to checking for this flag is consistent with some (but not all) others in this file,\n\t// but not with tools/benchmark/src/Configuration.ts.\n\t// For now, undefined, \"1\" and \"true\" should work consistently across all known use, and \"1\" is the main form we explicitly use.\n\t// All these should be made to match, see AB#69054.\n\tif (process.env.FLUID_TEST_PERF_MODE !== undefined) {\n\t\tif (process.env.SILENT_TEST_OUTPUT === undefined) {\n\t\t\tconsole.log(`Running performance tests...`);\n\t\t}\n\n\t\t// Some perf tests are often quite slow, and we don't want to lose the data by hitting a timeout.\n\t\t// This is 1000 seconds, so ~16 minutes.\n\t\t// This can be overridden by setting FLUID_TEST_TIMEOUT to a different value if desired.\n\t\tconfig.timeout = 1_000_000;\n\n\t\t// If there is no filter specified, limit to benchmarks.\n\t\t// If mocha allowed multiple filters to all be applied to further narrow results, we would do this unconditionally.\n\t\tif (!(process.argv.includes(\"--fgrep\") || process.argv.includes(\"--grep\"))) {\n\t\t\tconfig.fgrep = [\"@Benchmark\"];\n\t\t}\n\n\t\tconfig.reporter = \"@fluid-tools/benchmark/dist/mocha/Reporter.js\";\n\t\tif (!process.argv.includes(\"--reporterOptions\")) {\n\t\t\t// If report options were not specified, default to:\n\t\t\tconfig.reporterOptions = [\"reportFile=./benchmarkOutput.json\"];\n\t\t}\n\t} else {\n\t\tconst packageJsonPath = path.join(packageDir, \"package.json\");\n\t\tconst packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as {\n\t\t\tname: string;\n\t\t};\n\t\tconfig.reporter = `mocha-multi-reporters`;\n\t\t// See https://www.npmjs.com/package/mocha-multi-reporters#cmroutput-option\n\n\t\tconst outputFilePrefix = reportPrefix !== undefined ? `${reportPrefix}-` : \"\";\n\t\tif (process.env.SILENT_TEST_OUTPUT === undefined) {\n\t\t\tconsole.log(\n\t\t\t\t`Writing test results relative to package to nyc/${outputFilePrefix}junit-report.xml`,\n\t\t\t);\n\t\t}\n\t\tconst suiteName =\n\t\t\treportPrefix !== undefined ? `${packageJson.name} - ${reportPrefix}` : packageJson.name;\n\t\t// This must be the exact module specifier mocha-multi-reporters will `require(...)` to load the reporter\n\t\t// (see its source: https://github.com/stevemao/mocha-multi-reporters/blob/master/lib/MultiReporters.js),\n\t\t// i.e. it can't be shortened to some arbitrary friendly name. It also determines the reporter-specific\n\t\t// option key mocha-multi-reporters expects below (and in test-config.json): it camelCases this exact\n\t\t// string and appends \"ReporterOptions\" (e.g. \"@foo/bar/baz\" -> \"fooBarBazReporterOptions\").\n\t\tconst xunitReporterName = \"@fluid-internal/mocha-test-setup/xunit-reporter\";\n\t\tconfig[\"reporter-options\"] = [\n\t\t\t`configFile=${path.join(\n\t\t\t\timport.meta.dirname,\n\t\t\t\t\"..\",\n\t\t\t\t\"test-config.json\",\n\t\t\t)},cmrOutput=${xunitReporterName}+output+${outputFilePrefix}:${xunitReporterName}+suiteName+${suiteName}`,\n\t\t];\n\t}\n\n\tif (process.env.FLUID_TEST_TIMEOUT !== undefined) {\n\t\tconfig.timeout = process.env.FLUID_TEST_TIMEOUT;\n\t}\n\n\tif (process.env.FLUID_TEST_FORBID_ONLY !== undefined) {\n\t\tconfig[\"forbid-only\"] = true;\n\t}\n\n\treturn config;\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 = "3.
|
|
8
|
+
export declare const pkgVersion = "3.6.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
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,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.
|
|
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.6.0\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-internal/mocha-test-setup",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Utilities for Fluid tests",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@fluid-internal/test-driver-definitions": "~3.
|
|
30
|
-
"@fluidframework/core-interfaces": "~3.
|
|
29
|
+
"@fluid-internal/test-driver-definitions": "~3.6.0",
|
|
30
|
+
"@fluidframework/core-interfaces": "~3.6.0",
|
|
31
31
|
"mocha": "^11.7.5",
|
|
32
32
|
"source-map-support": "^0.5.21"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
36
36
|
"@biomejs/biome": "~2.4.5",
|
|
37
|
-
"@fluid-tools/build-cli": "^0.
|
|
37
|
+
"@fluid-tools/build-cli": "^0.68.0",
|
|
38
38
|
"@fluidframework/build-common": "^2.0.3",
|
|
39
|
-
"@fluidframework/build-tools": "^0.
|
|
39
|
+
"@fluidframework/build-tools": "^0.68.0",
|
|
40
40
|
"@fluidframework/eslint-config-fluid": "^14.0.0",
|
|
41
41
|
"@microsoft/api-extractor": "7.58.1",
|
|
42
42
|
"@types/mocha": "^10.0.10",
|
package/src/mocharcCommon.ts
CHANGED
|
@@ -26,6 +26,16 @@ export interface FluidTestMochaConfig {
|
|
|
26
26
|
"forbid-only"?: boolean;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/* eslint-disable @fluid-internal/fluid/no-markdown-links-in-jsdoc --
|
|
30
|
+
This configuration helper is not published in API docs so we can keep its README link source-relative.
|
|
31
|
+
Sadly there seems to be no way to link the readme file with {@link} tags nor raw file urls that can actually be clicked in VS-Code
|
|
32
|
+
(directly or via intellisense) without giving errors due to needing to navigate up via `..` which is blocked.
|
|
33
|
+
There also seems to be no way to make this link go to the relevant anchor in the README file as vscode interprets it as part of the file name,
|
|
34
|
+
rather than recognizing it as an anchor within the file.
|
|
35
|
+
I still think using this non anchored markdown link is better than linking to a URL on github which points either to this branch,
|
|
36
|
+
or main where these docs don't even exist yet.
|
|
37
|
+
Thus I feel this lint suppression allows for a better link, and thus is justified.
|
|
38
|
+
*/
|
|
29
39
|
/**
|
|
30
40
|
* Get the mocha configuration for running tests using the conventions followed in the Fluid Framework repository.
|
|
31
41
|
*
|
|
@@ -33,10 +43,13 @@ export interface FluidTestMochaConfig {
|
|
|
33
43
|
* @param additionalRequiredModules - modules to require in addition to the standard set.
|
|
34
44
|
* @param testReportPrefix - prefix for the test output report file names.
|
|
35
45
|
* @remarks
|
|
36
|
-
*
|
|
46
|
+
* See the "Running tests" section in [README.md](../README.md)
|
|
47
|
+
* for test selection, performance measurements, and environment variable configuration.
|
|
37
48
|
*
|
|
38
|
-
*
|
|
49
|
+
* Mocha’s CLI `spec` arguments add to the configured selection rather than replacing it.
|
|
50
|
+
* For exact control over `spec` (including via the CLI), replace or delete the `spec` property in the returned configuration.
|
|
39
51
|
*/
|
|
52
|
+
/* eslint-enable @fluid-internal/fluid/no-markdown-links-in-jsdoc -- see the disable for details */
|
|
40
53
|
export function getFluidTestMochaConfig(
|
|
41
54
|
packageDir: string,
|
|
42
55
|
additionalRequiredModules?: string[],
|
package/src/packageVersion.ts
CHANGED