Skip to content

test(oauth): use node:test mocks instead of sinon - #2817

Merged
mwbrooks merged 2 commits into
mainfrom
test-oauth-node-test-mocks
Nov 5, 2026
Merged

mwbrooks merged 2 commits into
mainfrom
test-oauth-node-test-mocks

Conversation

@WilliamBergamin

@WilliamBergamin WilliamBergamin commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This pull request replaces sinon with the built-in node:test mocks in @slack/oauth tests and removes sinon from its devDependencies. It follows #2811, which did the same for @slack/cli-hooks.

  • Asserts now check the exact calls made. The old substring checks still passed if the store deleted files from the wrong directory.
  • The "latest" test turns history off, so it checks every file it writes.
  • The 14 copied fake state stores are now one createFakeStateStore() helper.

Testing

  1. In src/installation-stores/file-store.ts, change deleteFile(path.join(installationDir, filePath)) to deleteFile(filePath). Both delete tests fail (they pass on main). Revert.
  2. From packages/oauth, run node --import tsx --test 'src/**/*.test.ts'. All 76 tests pass. (npm test only runs 16 of them until build: run every test file in oauth and cli-test #2818 merges.)

Requirements

🤖 Generated with Claude Code

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@changeset-bot

changeset-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d9fb273

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.83%. Comparing base (ae8f4cd) to head (d9fb273).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2817      +/-   ##
==========================================
+ Coverage   93.77%   93.83%   +0.05%     
==========================================
  Files          66       66              
  Lines       10571    10571              
  Branches      611      611              
==========================================
+ Hits         9913     9919       +6     
+ Misses        621      616       -5     
+ Partials       37       36       -1     
Flag Coverage Δ
cli-hooks 93.75% <ø> (ø)
cli-test 93.75% <ø> (ø)
logger 93.75% <ø> (ø)
oauth 93.75% <ø> (ø)
socket-mode 93.75% <ø> (ø)
web-api 93.75% <ø> (ø)
webhook 93.75% <ø> (ø)

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@WilliamBergamin WilliamBergamin added tests M-T: Testing work only pkg:oauth applies to `@slack/oauth` dependencies Pull requests that update a dependency file semver:patch labels Nov 5, 2026
@WilliamBergamin
WilliamBergamin marked this pull request as ready for review November 5, 2026 16:35
@WilliamBergamin
WilliamBergamin requested a review from a team as a code owner November 5, 2026 16:35

@mwbrooks mwbrooks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

✅ Thanks @WilliamBergamin! Folding the 14 copied state stores into one helper makes these tests so much easier to read.

// fsReaddirSync returns ['app-latest', 'user-userId-latest']
assert.strictEqual(fsUnlinkSync.callCount, 2);
assert.deepEqual(callsTo(fsReaddirSync), [[fakeInstallDir]]);
assert.deepEqual(callsTo(fsUnlinkSync), [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

praise: Asserting the exact unlink paths is a real upgrade, since the old substring match passed even when the store deleted from the wrong directory 🎯

@mwbrooks
mwbrooks merged commit 822f6a4 into main Nov 5, 2026
22 checks passed
@mwbrooks
mwbrooks deleted the test-oauth-node-test-mocks branch November 5, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file pkg:oauth applies to `@slack/oauth` semver:patch tests M-T: Testing work only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants