Skip to content

Migration esm#2683

Merged
fatso83 merged 37 commits intomainfrom
migration-esm
Apr 9, 2026
Merged

Migration esm#2683
fatso83 merged 37 commits intomainfrom
migration-esm

Conversation

@fatso83
Copy link
Copy Markdown
Contributor

@fatso83 fatso83 commented Apr 2, 2026

Purpose (TL;DR) - mandatory

Convert the project to ESM while keeping the API unchanged for consumers

short summary of changes

  • src/ is the authored source.
  • lib/ is generated output for CommonJS compatibility and should not be committed.
  • pkg/ is the browser/ESM publish bundle.

@fatso83 fatso83 marked this pull request as draft April 2, 2026 00:45
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 98.36066% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.28%. Comparing base (cd2bf5a) to head (6ddc65d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/sinon/sandbox.js 97.08% 3 Missing ⚠️
src/sinon/util/core/wrap-method.js 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2683      +/-   ##
==========================================
+ Coverage   95.82%   97.28%   +1.46%     
==========================================
  Files          39       39              
  Lines        1892     1771     -121     
==========================================
- Hits         1813     1723      -90     
+ Misses         79       48      -31     
Flag Coverage Δ
unit 97.28% <98.36%> (+1.46%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fatso83 fatso83 marked this pull request as ready for review April 6, 2026 12:26
@fatso83 fatso83 merged commit 819bb64 into main Apr 9, 2026
15 checks passed
@fatso83 fatso83 deleted the migration-esm branch April 9, 2026 10:35
fatso83 pushed a commit that referenced this pull request May 5, 2026
The ESM port of `createApi` (#2683, shipped in 21.1.0) replaced  `createSandbox: createSandbox` with a wrapper that pushes every newly-created sandbox into the root sandbox's fake collection:

    createSandbox: function createSandbox(config) {
        const s = createConfiguredSandbox(config);
        sandbox.getFakes().push(s);
        return s;
    }

`Sandbox#restore` then walks that collection and calls `.restore()` on each entry. Because a sub-sandbox is itself an entry, every top-level `sinon.restore()` cascades into every sub-sandbox and undoes its stubs/timers/etc. — defeating the whole point of having an isolated sub-sandbox. The same cascade hits `resetHistory` and
`verifyAndRestore`. This is the regression reported in #2701.

Restore the pre-21.1 behaviour: hand the root API a direct reference to `createConfiguredSandbox`. Sub-sandboxes are now isolated; only `subSandbox.restore()` (or `verifyAndRestore`) clears their fakes.

Also flip the four sandbox tests that were locking in the buggy cascade: they now assert the parent's restore/resetHistory leaves the child untouched, with an explicit child-side cleanup at the
end.

Closes #2701
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.

1 participant