Skip to content

Commit 1bcd572

Browse files
committed
test(client): distinguish variant test cases
Several test suites run with varying environments but report tests the same way (most meaningfully by name) that are tracked as the same by infrastructure. Update default setup to prefix test case names by variance when it is present. Reconfigure CommonJS testing as a variant and replace MOCHA_SPEC using new FLUID_TEST_MODULE_SYSTEM environment variable. CommonJS test cases are prefixed by `[CJS]`. ESM tests remain unprefixed. `@fluidframework/core-interfaces` which is unable to leverage `@fluid-internal/mocha-test-setup` has a cloned subset of logic and now generates reports. Its test spec was restored to `*.spec.*js` which allowed `src/test/types/fluidObjectTypes.ts` to be restored from #25292 changes.
1 parent 815e150 commit 1bcd572

File tree

70 files changed

+240
-183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+240
-183
lines changed

examples/utils/import-testing/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"lint:fix": "fluid-build . --task eslint:fix --task format",
3232
"test": "npm run test:mocha",
3333
"test:mocha": "npm run test:mocha:esm && npm run test:mocha:cjs",
34-
"test:mocha:cjs": "cross-env MOCHA_SPEC=dist/test mocha",
34+
"test:mocha:cjs": "cross-env FLUID_TEST_MODULE_SYSTEM=CJS mocha",
3535
"test:mocha:esm": "mocha",
3636
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
3737
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist"

examples/utils/webpack-fluid-loader/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"test": "npm run test:mocha",
5353
"test:coverage": "c8 npm test",
5454
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
55-
"test:mocha:cjs": "cross-env MOCHA_SPEC=dist/test mocha",
55+
"test:mocha:cjs": "cross-env FLUID_TEST_MODULE_SYSTEM=CJS mocha",
5656
"test:mocha:esm": "mocha",
5757
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
5858
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",

experimental/PropertyDDS/packages/property-changeset/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"test": "npm run test:mocha",
5353
"test:coverage": "c8 npm test",
5454
"test:mocha": "npm run test:mocha:esm && npm run test:mocha:cjs",
55-
"test:mocha:cjs": "cross-env MOCHA_SPEC=dist/test mocha",
55+
"test:mocha:cjs": "cross-env FLUID_TEST_MODULE_SYSTEM=CJS mocha",
5656
"test:mocha:esm": "mocha",
5757
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
5858
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../../common/build/build-common/src/cjs/package.json ./dist"

experimental/PropertyDDS/packages/property-dds/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"lint:fix": "fluid-build . --task eslint:fix --task format",
4949
"test": "npm run test:mocha",
5050
"test:mocha": "npm run test:mocha:esm && echo skipping cjs due to high overhead - npm run test:mocha:cjs",
51-
"test:mocha:cjs": "cross-env MOCHA_SPEC=dist/test mocha",
51+
"test:mocha:cjs": "cross-env FLUID_TEST_MODULE_SYSTEM=CJS mocha",
5252
"test:mocha:esm": "mocha",
5353
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
5454
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../../common/build/build-common/src/cjs/package.json ./dist"

experimental/dds/ot/ot/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"test": "npm run test:mocha",
5555
"test:coverage": "c8 npm test",
5656
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
57-
"test:mocha:cjs": "cross-env MOCHA_SPEC=dist/test mocha",
57+
"test:mocha:cjs": "cross-env FLUID_TEST_MODULE_SYSTEM=CJS mocha",
5858
"test:mocha:esm": "mocha",
5959
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
6060
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../../common/build/build-common/src/cjs/package.json ./dist"

experimental/dds/ot/sharejs/json1/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"test": "npm run test:mocha",
5656
"test:coverage": "c8 npm test",
5757
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
58-
"test:mocha:cjs": "cross-env MOCHA_SPEC=dist/test mocha",
58+
"test:mocha:cjs": "cross-env FLUID_TEST_MODULE_SYSTEM=CJS mocha",
5959
"test:mocha:esm": "mocha",
6060
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
6161
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../../../common/build/build-common/src/cjs/package.json ./dist"

experimental/dds/sequence-deprecated/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"test": "npm run test:mocha",
5555
"test:coverage": "c8 npm test",
5656
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
57-
"test:mocha:cjs": "cross-env MOCHA_SPEC=dist/test mocha",
57+
"test:mocha:cjs": "cross-env FLUID_TEST_MODULE_SYSTEM=CJS mocha",
5858
"test:mocha:esm": "mocha",
5959
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
6060
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",

experimental/framework/tree-react-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"test": "npm run test:mocha",
6868
"test:coverage": "c8 npm test",
6969
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
70-
"test:mocha:cjs": "cross-env MOCHA_SPEC=dist/test mocha",
70+
"test:mocha:cjs": "cross-env FLUID_TEST_MODULE_SYSTEM=CJS mocha",
7171
"test:mocha:esm": "mocha",
7272
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
7373
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist"

packages/common/client-utils/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@
103103
"test:coverage": "c8 npm test",
104104
"test:jest": "jest --ci",
105105
"test:mocha": "npm run test:mocha:esm && npm run test:mocha:cjs",
106-
"test:mocha:cjs": "cross-env MOCHA_SPEC=dist/test/mocha mocha",
107-
"test:mocha:esm": "cross-env MOCHA_SPEC=lib/test/mocha mocha",
106+
"test:mocha:cjs": "cross-env FLUID_TEST_MODULE_SYSTEM=CJS \"MOCHA_SPEC=dist/test/mocha/**/*.spec.*js\" mocha",
107+
"test:mocha:esm": "cross-env \"MOCHA_SPEC=lib/test/mocha/**/*.spec.*js\" mocha",
108108
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
109109
"typetests:gen": "flub generate typetests --dir . -v",
110110
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"

packages/common/core-interfaces/.mocharc.cjs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,16 @@
77

88
// @fluid-internal/mocha-test-setup depends on this package, so we can't use it.
99

10-
module.exports = { recursive: true };
10+
const testCJS = process.env.FLUID_TEST_MODULE_SYSTEM === "CJS";
11+
const outputFilePrefix = testCJS ? "CJS-" : "";
12+
const suiteName = "@fluidframework/core-interfaces" + (testCJS ? " - CJS" : "");
13+
module.exports = {
14+
spec: testCJS ? "dist/test/**/*.spec.*js" : "lib/test/**/*.spec.*js",
15+
recursive: true,
16+
require: [testCJS ? "./dist/test/mochaHooks.js" : "./lib/test/mochaHooks.js"],
17+
reporter: "mocha-multi-reporters",
18+
"reporter-options": [
19+
`configFile=test-config.json,cmrOutput=xunit+output+${outputFilePrefix}:xunit+suiteName+${suiteName}`,
20+
],
21+
"unhandled-rejections": "strict",
22+
};

0 commit comments

Comments
 (0)