Skip to content

test(client-local-server-*tests): test ESM#27322

Open
jason-ha wants to merge 2 commits into
microsoft:mainfrom
jason-ha:test/build/local-server-to-esm
Open

test(client-local-server-*tests): test ESM#27322
jason-ha wants to merge 2 commits into
microsoft:mainfrom
jason-ha:test/build/local-server-to-esm

Conversation

@jason-ha
Copy link
Copy Markdown
Contributor

@jason-ha jason-ha commented May 15, 2026

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.

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.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

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:

  • Correctness — logic errors, race conditions, lifecycle issues
  • Security — vulnerabilities, secret exposure, injection
  • API Compatibility — breaking changes, release tags, type design
  • Performance — algorithmic regressions, memory leaks
  • Testing — coverage gaps, hollow tests

How this works

  • Adjust the reviewer set by ticking/unticking boxes above. Reviewer toggles alone don't trigger anything.

  • Tick Start review below to dispatch the review fleet.

  • After review finishes, tick Start review again to request another run — it auto-resets after each dispatch.

  • This comment updates as new commits land; your reviewer selections are preserved.

  • Start review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@alexvy86
Copy link
Copy Markdown
Contributor

Move files spec from mocha command lines (was ignored) [...]

Curious, why was it ignored?

@jason-ha
Copy link
Copy Markdown
Contributor Author

Move files spec from mocha command lines (was ignored) [...]

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",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that mocha was only compatible with CJS? Why does this work here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants