Repository navigation
[SPFx 1.23.2 / 1.24.0-beta.2] heft test / Jest fails: sp-core-library unconditionally requires unpublished @msinternal/* packages #11035
Description
Activity
- addedtype:bug-suspectedSuspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.
on Sep 24, 2026 m365-agent-toolkit-assistant commented
on Sep 24, 2026 More actions👋 Hi Julie Turner (@juliemturner),
Thank you for reporting this issue! We want to let you know that:
⏱️ Our team will personally review your issue
🎯 You can expect a response within 1 business day✨ This is an AI-generated initial response
🤖 AI-Generated Preliminary Analysis:Classification: Bug — the report is consistent with an SPFx package-publication defect: supported Heft/Jest tests cannot resolve a statically imported, unpublished dependency.
- SPFx 1.23 uses Heft, which officially invokes Jest for testing.
type:bug-suspectedsupports triage but is not maintainer confirmation; the exact root cause remains tentative.- No duplicate or official known-issue entry was found.
Upgrade check: 1.23.2 is the latest GA reported here. The newer 1.24 beta.5 release notes contain no matching fix, so no fixing version is confirmed.
What to do now:
- Re-test the minimal reproduction on 1.24 beta.5.
- Keep a narrowly scoped Jest
moduleNameMappermock for required@msinternal/*modules; avoid broadly masking modules whose behavior is under test. - Provide the lockfile and minimal repository for engineering validation.
Useful links:
- Heft-based SPFx toolchain
- SPFx 1.24 preview notes
- No sufficiently relevant related issue found in the searched repos.
Note: This is an automated first response generated by AI. A human team member will review your issue and provide a more detailed response soon. We appreciate your patience!
- addedsharepoint-developer-supportsharepoint-developer-supportsharepoint-developer-supportand removed
on Sep 25, 2026 Hi
We were able to successfully reproduce the reported SPFx 1.23.2 Heft/Jest issue.
Repro: A minimal Jest test importing AadHttpClient from @microsoft/sp-http fails during test-suite initialization with:Cannot find module '@msinternal/ecs-flight'
The require stack goes through @microsoft/sp-http → @microsoft/sp-http-base → @microsoft/sp-core-library → SPFlight.js, where @msinternal/ecs-flight is required.
We will raise a bug with the engineering team for further investigation.
- addedtype:bug-confirmedConfirmed bug, not working as designed / expected.Confirmed bug, not working as designed / expected.and removedtype:bug-suspectedSuspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.
on Sep 25, 2026
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
💥 SharePoint Framework
Developer environment
Windows
What browser(s) / client(s) have you tested
Additional environment details
Describe the bug / error
@microsoft/sp-core-library's compiled SPFlight.js and SPExperiment.js modules contain unconditional,
top-level require()/import statements for Microsoft-internal packages — e.g. @msinternal/ecs-flight
and @msinternal/odsp-core-bundle. Scanning the wider @microsoft/sp-* dependency tree turns up dozens
more of these (@msinternal/odsp-datasources, @msinternal/odsp-utilities, @msinternal/sp-telemetry,
@msinternal/sp-safehtml, etc.).
These @msinternal/* packages are listed only under sp-core-library's own devDependencies (never as a
regular "dependency"), are not published to the public npm registry, and are therefore never present
in a consuming project's node_modules.
In a production Webpack build this goes unnoticed, since nothing in application code calls SPFlight/
SPExperiment directly, so tree-shaking drops the unused re-export before Webpack needs to resolve the
import. But
heft test(Jest) eagerly evaluates CommonJS modules with a plain require(), whichunconditionally runs sp-core-library's module top-level code — including the @msinternal/* require —
for any test file that transitively imports @microsoft/sp-http's AadHttpClient (or anything else in
the dependency graph that reaches SPFlight.js/SPExperiment.js). The test suite fails to even load:
Cannot find module '@msinternal/ecs-flight' from 'node_modules/@microsoft/sp-core-library/lib-commonjs/SPFlight.js'
Require stack:
node_modules/@microsoft/sp-core-library/lib-commonjs/SPFlight.js
node_modules/@microsoft/sp-core-library/lib-commonjs/index.js
node_modules/@microsoft/sp-http-base/lib-commonjs/aadHttpClient/AadHttpClient.js
node_modules/@microsoft/sp-http-base/lib-commonjs/index.js
node_modules/@microsoft/sp-http/lib-commonjs/index.js
This reproduces identically on both the current GA release (1.23.2) and the 1.24.0-beta.2
— the compiled output style changed (tslib helpers in 1.23.2 vs. @swc/helpers
in 1.24.0-beta.2), but the unconditional require("@msinternal/ecs-flight") at the top of SPFlight.js
is unchanged between versions.
The default Jest config shipped by @microsoft/spfx-web-build-rig / @rushstack/heft-jest-plugin has no
moduleNameMapper/transformIgnorePatterns entry to protect against this, so any SPFx project scaffolded
with --use-heft (the current default/only build system) hits this the moment a test touches
AadHttpClient, SPComponentLoader, or anything else that pulls in sp-core-library's flighting code —
with zero custom application code involved.
Steps to reproduce
Scaffold (or open) any Heft-based SPFx project on 1.23.2 or 1.24.0-beta.2 that depends on @microsoft/sp-http.
Add a trivial test file, e.g.:
import { AadHttpClient } from '@microsoft/sp-http';
test('sp-http imports without crashing', () => {
expect(AadHttpClient).toBeDefined();
});
Run
heft test --clean(ornpm run test).Observe: "Cannot find module '@msinternal/ecs-flight'" — the test suite fails to run at all.
Expected behavior
heft test/ Jest should be able to load and run tests that import @microsoft/sp-http (or any other@microsoft/sp-* package) without requiring knowledge of Microsoft-internal, unpublished @msinternal/*
packages. Either:
packages that are only its own devDependencies and are never published (e.g. gate them behind a
dynamic require/lazy accessor, or strip the dead code path from the published build), or
stub out the @msinternal/* scope out of the box.
We worked around it locally with a project-level Jest moduleNameMapper regex stub for ^@msinternal/.*$,
but this shouldn't be necessary for a first-party Microsoft package to be testable.