Skip to content

build: use node test runner for workspace packages#2529

Merged
zimeg merged 25 commits intomainfrom
test
Mar 3, 2026
Merged

build: use node test runner for workspace packages#2529
zimeg merged 25 commits intomainfrom
test

Conversation

@zimeg
Copy link
Copy Markdown
Member

@zimeg zimeg commented Mar 3, 2026

Summary

This PR uses the node test runner for unit tests of workspace packages - #2359 🎁

$ npm test
$ npm test --workspace=@slack/web-api

Also removed are packages used for testing before for fewer dependencies overall:

  • Before: 628 packages
  • After: 507 packages

These include kind development dependencies: 👾 ✨

Notes

  • The testing matrix is reduced to 6 runners - one for each OS and node version - since unit tests for all packages take around one minute altogether. We hope to reduce computation time from 4820 seconds to much less!

Requirements

@zimeg zimeg self-assigned this Mar 3, 2026
@zimeg zimeg requested a review from a team as a code owner March 3, 2026 07:11
@zimeg zimeg added semver:patch tests M-T: Testing work only pkg:web-api applies to `@slack/web-api` pkg:rtm-api applies to `@slack/rtm-api` pkg:webhook applies to `@slack/webhook` pkg:logger applies to `@slack/logger` pkg:oauth applies to `@slack/oauth` pkg:socket-mode applies to `@slack/socket-mode` pkg:cli-hooks applies to `@slack/cli-hooks` pkg:cli-test applies to `@slack/cli-test` labels Mar 3, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 3, 2026

🦋 Changeset detected

Latest commit: 55cf42e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@slack/oauth Patch

Not sure what this means? Click here to learn what changesets are.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 97.88918% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.66%. Comparing base (57f4f22) to head (55cf42e).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2529      +/-   ##
==========================================
- Coverage   93.17%   90.66%   -2.51%     
==========================================
  Files          40       82      +42     
  Lines       11384    14980    +3596     
  Branches      726      508     -218     
==========================================
+ Hits        10607    13582    +2975     
- Misses        765     1373     +608     
- Partials       12       25      +13     
Flag Coverage Δ
cli-hooks 90.66% <97.88%> (-4.77%) ⬇️
cli-test 90.66% <97.88%> (-4.13%) ⬇️
logger 90.66% <97.88%> (?)
oauth 90.66% <97.88%> (+13.26%) ⬆️
socket-mode 90.66% <97.88%> (+28.78%) ⬆️
web-api 90.66% <97.88%> (-7.47%) ⬇️
webhook 90.66% <97.88%> (-6.00%) ⬇️

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.

Copy link
Copy Markdown
Contributor

@srtaalej srtaalej left a comment

Choose a reason for hiding this comment

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

thanks for maintaining our code health ⭐! looks like codecov is being finicky but would be great to land this once thats resolved 💫 🚀

Comment thread .claude/settings.json
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.

🤩

@zimeg zimeg linked an issue Mar 3, 2026 that may be closed by this pull request
7 tasks
@zimeg zimeg added the bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented label Mar 3, 2026
Copy link
Copy Markdown
Member Author

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

@srtaalej Thanks so much for reviewing this! I made a few more changes and left some comments of thoughts.

...codecov is being finicky

I'm noticing this too but think the most recent "error" is from test coverage decreasing. I understand the node test runner to be more honest about this so this is expected to me with these changes 🫡

Let's continue to improve code health so future changes can be made fast! I think this PR points at an area of @slack/socket-mode that we might revisit for example 🔍

Comment on lines -50 to +51
const tempDir = path.join(process.cwd(), 'tmp');
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'check-update-'));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

👁️‍🗨️ note: Here we're avoiding a stalemate when multiple tests run at the same time. Now we instead use separate tmp directories!

Comment on lines +55 to 57
sinon.stub(childProcess, 'exec').callsFake((command, cb) => {
cb(null, { stdout: mockNPM(command), stderr: '' });
});
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

📺 note: We stub the exec process now instead of the waiting of it without needing to change calling code! This ought be a more true stub I think!

"rewiremock": "^3",
"shx": "^0.4.0",
"sinon": "^21",
"source-map-support": "^0.5.21",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🪓 note: It was unclear to me how source-map-support was being used at first, but I find this to exist alongside the c8 configurations that are also removed.

"sinon": "^21",
"source-map-support": "^0.5.21",
"ts-node": "^10",
"tsx": "^4.20.6",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🎁 note: We prefer tsx with these latest changes instead of ts-node for imports into the test:

📚 https://nodejs.org/en/learn/typescript/run

Comment on lines +47 to +48
// Use require() so rewiremock can intercept @slack/web-api dependency
var { InstallProvider } = require('./index') as typeof import('./index');
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🧪 note: I'm not thrilled with unordered imports but this seems to be clear and meaningful to keep in tests, without updating the linting rules.

🗣️ ramble: We should perhaps consider changing the mocks we have to be at the Web API call and not method but that's outside the scope of these changes for now.

Comment on lines -48 to +49
writeToFile(`${installationDir}/app-latest`, installationData);
writeToFile(`${installationDir}/user-${user.id}-latest`, installationData);
writeToFile(path.join(installationDir, 'app-latest'), installationData);
writeToFile(path.join(installationDir, `user-${user.id}-latest`), installationData);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🗣️ note: This change is to production code to improve our tests on Windows! I added a changeset for this here in c3d1f1a.

Comment on lines +235 to +239
// Swallow unhandled rejections from internal reconnection cleanup
process.emit = (event, ...args) => {
if (event === 'unhandledRejection') return true;
return originalEmit(event, ...args);
};
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

👁️‍🗨️ note: Perhaps related to #1787 but let's continue investigation later. We added this to avoid flaky tests for now.

Comment on lines 208 to +222
do {
await sleep(2);
await sleep(5);
retries = closed;
elapseTime = Date.now() - startTime;
} while (retries < 2 && elapseTime < 50);
// after less then 50 milliseconds, with a timeout of 20ms, we would expect 2 retries.
} while (retries < 2 && elapseTime < 2000);
// with a clientPingTimeout of 20ms, we would expect 2 retries well within 2 seconds.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

📝 note: Here we're padding our possible timing for edges that might exist on Windows startup.

@zimeg zimeg merged commit dbd38e2 into main Mar 3, 2026
14 of 16 checks passed
@zimeg zimeg deleted the test branch March 3, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented pkg:cli-hooks applies to `@slack/cli-hooks` pkg:cli-test applies to `@slack/cli-test` pkg:logger applies to `@slack/logger` pkg:oauth applies to `@slack/oauth` pkg:rtm-api applies to `@slack/rtm-api` pkg:socket-mode applies to `@slack/socket-mode` pkg:web-api applies to `@slack/web-api` pkg:webhook applies to `@slack/webhook` semver:patch tests M-T: Testing work only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix flaky Windows 18.x and 22.x unit tests

2 participants