test(client-local-server-*tests): test ESM#27322
Conversation
Stop "lying" that ESM is tested (there was not CJS test label) and actually test ESM that we care more about. Note that all server packages (server workspaces) are CJS only. 1. Update packages to type "module" (ESM) - ran ts2esm that added missing .js extensions to import spec - dirname.cts removed in favor of ESM only import.meta.url use. 2. Adopt standardized test patterns - Move files spec from mocha command lines (was ignored) to config file. - Move test support files under src/test instead of just src/. - Move stress package tsconfig.json to under src/test. 3. Fix sequence build deps to allow build-and-test:unit:esm from stress package.
|
Hi! Thank you for opening this PR. Want me to review it? Based on the diff (128 lines, 27 files), I've queued these reviewers:
How this works
|
There was a problem hiding this comment.
Pull request overview
This PR converts local server test packages toward ESM-based test execution and reorganizes local-server stress test support code under src/test, while updating build/test scripts and dependencies to target ESM outputs.
Changes:
- Switch local-server test packages from CommonJS to ESM test builds and Mocha config-based test discovery.
- Move/update stress harness utilities and imports to ESM-compatible paths.
- Split Sequence test build dependencies by CJS/ESM so ESM stress tests can depend on ESM test outputs.
Reviewed changes
Copilot reviewed 20 out of 27 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/test/local-server-tests/src/test/utils.ts |
Adds local test loader helper under src/test. |
packages/test/local-server-tests/src/test/tsconfig.json |
Updates test compile root/output to lib/test. |
packages/test/local-server-tests/src/test/synchronousDataStoreCreation.spec.ts |
Updates helper import path. |
packages/test/local-server-tests/src/test/stagingMode.spec.ts |
Updates helper import path. |
packages/test/local-server-tests/src/test/readonly.spec.ts |
Updates helper import path. |
packages/test/local-server-tests/src/test/pendingLocalStateStore.spec.ts |
Updates helper import path. |
packages/test/local-server-tests/src/test/loadFrozenContainerFromPendingState.spec.ts |
Updates helper import path. |
packages/test/local-server-tests/src/test/handleResolution.spec.ts |
Updates helper import path and extension. |
packages/test/local-server-tests/src/test/decoupledCreate.spec.ts |
Updates helper import path. |
packages/test/local-server-tests/src/test/captureFullContainerState.spec.ts |
Updates helper import path. |
packages/test/local-server-tests/package.json |
Switches package/test scripts and fluid-build task to ESM. |
packages/test/local-server-tests/.mocharc.cjs |
Moves Mocha spec glob into config. |
packages/test/local-server-stress-tests/src/test/utils.ts |
Adds unreachable-code-path proxy helper. |
packages/test/local-server-stress-tests/src/test/tsconfig.json |
Moves stress test tsconfig under src/test and updates output. |
packages/test/local-server-stress-tests/src/test/stressDataObject.ts |
Adds stress test data object/runtime factory implementation. |
packages/test/local-server-stress-tests/src/test/localServerStressHarness.ts |
Adds local-server stress harness implementation. |
packages/test/local-server-stress-tests/src/test/localServerStress.spec.ts |
Updates stress test imports to local ESM paths. |
packages/test/local-server-stress-tests/src/test/dynamicWeightGenerator.ts |
Adds dynamic-weight async generator utility. |
packages/test/local-server-stress-tests/src/test/ddsOperations.ts |
Adds DDS operation conversion/reduction/validation helpers. |
packages/test/local-server-stress-tests/src/test/ddsModels.ts |
Adds DDS model registry for stress tests. |
packages/test/local-server-stress-tests/src/test/dataStoreOperations.ts |
Updates stress harness type import path. |
packages/test/local-server-stress-tests/src/test/baseModel.ts |
Updates imports and replaces CJS dirname helper with import.meta.url. |
packages/test/local-server-stress-tests/src/dirname.cts |
Removes CJS dirname shim. |
packages/test/local-server-stress-tests/package.json |
Switches package/test scripts and stress build dependencies to ESM. |
packages/test/local-server-stress-tests/eslint.config.mts |
Points ESLint parser at moved stress test tsconfig. |
packages/test/local-server-stress-tests/.mocharc.cjs |
Moves Mocha spec glob into config and preserves forced exit. |
packages/dds/sequence/package.json |
Splits merge-tree test build dependencies into CJS and ESM tasks. |
Curious, why was it ignored? |
Yes. As of #25292 most mocha command line test specifications are ignored. |
| "test:coverage": "c8 npm test", | ||
| "test:mocha": "mocha \"lib/test/**/*.spec.*js\" --exit", | ||
| "test:mocha": "npm run test:mocha:esm", | ||
| "test:mocha:esm": "mocha", |
There was a problem hiding this comment.
I thought that mocha was only compatible with CJS? Why does this work here?
Stop "lying" that ESM is tested (there was not CJS test label) and actually test ESM that we care more about. Note that all server packages (server workspaces) are CJS only.