Skip to content

fix: resolve Mocha reporter from consuming package - #28053

Draft
Craig Macomber (Microsoft) (CraigMacomber) wants to merge 1 commit into
microsoft:mainfrom
CraigMacomber:fix/mocha-reporter-resolution
Draft

fix: resolve Mocha reporter from consuming package#28053
Craig Macomber (Microsoft) (CraigMacomber) wants to merge 1 commit into
microsoft:mainfrom
CraigMacomber:fix/mocha-reporter-resolution

Conversation

@CraigMacomber

@CraigMacomber Craig Macomber (Microsoft) (CraigMacomber) commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Description

Resolve mocha-multi-reporters from each consuming package before passing it to Mocha.

Mocha resolves a bare reporter name relative to its own installation. With pnpm's isolated dependency layout, the reporter can be available to the package running tests but unavailable from Mocha's virtual-store location, causing ERR_MOCHA_INVALID_REPORTER.

Resolving the reporter from the consuming package's package.json preserves package dependency ownership while making reporter loading independent of pnpm hoisting.

This error can also coincide with stale peer links in node_modules/.pnpm, particularly after dependency graph or peer-context changes. In the observed case, pnpm install --force did not repair the stale link. If reporter loading succeeds but another dependency fails with MODULE_NOT_FOUND, regenerate the installation from the repository root:

rm -rf node_modules
pnpm install --frozen-lockfile

This PR prevents reporter resolution from depending on pnpm's physical layout; it does not repair stale pnpm virtual-store links.

We do not know the source of the node_modules corruption, and it isn't repaired by pnpm install --force in pnpm 11 (but it is in the upcoming 12 release, though only when using --force, see pnpm/pnpm#9758 (comment))

Reviewer Guidance

The review process is outlined in the pull request guidelines.

Copilot AI lite review requested due to automatic review settings August 22, 2026 02:36
@github-actions github-actions Bot added area: tools area: repo Repo related work area: website area: tests Tests to add, test infrastructure improvements, etc base: main PRs targeted against main branch labels Aug 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi! Thank you for opening this PR. Want me to review it?

Based on the diff (3 lines, 1 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

Copilot AI left a comment

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.

Pull request overview

Update Fluid’s shared Mocha config helper so mocha-multi-reporters is resolved from the consuming package rather than from Mocha’s own installation, avoiding pnpm isolated-layout resolution failures (ERR_MOCHA_INVALID_REPORTER).

Changes:

  • Resolve mocha-multi-reporters via createRequire(packageJsonPath).resolve(...) anchored at the consuming package’s package.json.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 118 to +122
const packageJsonPath = path.join(packageDir, "package.json");
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8")) as {
name: string;
};
config.reporter = `mocha-multi-reporters`;
config.reporter = createRequire(packageJsonPath).resolve("mocha-multi-reporters");
@github-actions

Copy link
Copy Markdown
Contributor

Bundle size comparison

Base commit: 6c5e3810c1ea6f526df32533dbc0d7dcfb0b4a0f
Head commit: 76134c904b1d4c62bb7e5a9013dd55b232f4873a

Notable changes

No bundles changed by ≥ 500 bytes parsed.

Per-bundle deltas

@fluid-example/bundle-size-tests

  • fluidFrameworkAllAlpha.js: parsed 782419 → 782475 (+56), gzip 215012 → 215081 (+69)
  • azureClient.js: parsed 632351 → 632346 (-5), gzip 169408 → 169508 (+100)
  • odspClient.js: parsed 605567 → 605683 (+116), gzip 162931 → 163057 (+126)
  • aqueduct.js: parsed 536725 → 536736 (+11), gzip 144128 → 144169 (+41)
  • fluidFramework.js: parsed 401282 → 401315 (+33), gzip 114020 → 114062 (+42)
  • sharedTree.js: parsed 390661 → 390687 (+26), gzip 111446 → 111479 (+33)
  • containerRuntime.js: parsed 313633 → 313615 (-18), gzip 86019 → 86016 (-3)
  • sharedString.js: parsed 175134 → 175141 (+7), gzip 49635 → 49640 (+5)
  • experimentalSharedTree.js: parsed 161726 → 161726 (0), gzip 46665 → 46665 (0)
  • matrix.js: parsed 159511 → 159520 (+9), gzip 45849 → 45854 (+5)
  • loader.js: parsed 146720 → 146736 (+16), gzip 39875 → 39888 (+13)
  • odspDriver.js: parsed 111318 → 111394 (+76), gzip 34621 → 34698 (+77)
  • directory.js: parsed 65559 → 65566 (+7), gzip 18444 → 18451 (+7)
  • 578.js: parsed 58686 → 58686 (0), gzip 17657 → 17657 (0)
  • odspPrefetchSnapshot.js: parsed 45838 → 45819 (-19), gzip 15321 → 15331 (+10)
  • map.js: parsed 45710 → 45717 (+7), gzip 14077 → 14085 (+8)
  • 252.js: parsed 44362 → 44362 (0), gzip 13735 → 13735 (0)
  • summarizerDelayLoadedModule.js: parsed 31287 → 31287 (0), gzip 7929 → 7929 (0)
  • socketModule.js: parsed 26992 → 26962 (-30), gzip 8019 → 8053 (+34)
  • createNewModule.js: parsed 8523 → 8517 (-6), gzip 3550 → 3561 (+11)
  • odspPointInTime.js: parsed 5190 → 5184 (-6), gzip 2026 → 2028 (+2)
  • summaryModule.js: parsed 3888 → 3888 (0), gzip 1874 → 1874 (0)
  • connectionState.js: parsed 909 → 909 (0), gzip 500 → 500 (0)
  • sharedTreeAttributes.js: parsed 845 → 852 (+7), gzip 493 → 504 (+11)
  • debugAssert.js: parsed 429 → 429 (0), gzip 299 → 299 (0)
  • FluidFramework-HashFallback.js: parsed 419 → 419 (0), gzip 313 → 313 (0)

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

Labels

area: repo Repo related work area: tests Tests to add, test infrastructure improvements, etc area: tools area: website base: main PRs targeted against main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants