Repository navigation
Conversation
π¦ Changeset detectedLatest commit: 55cf42e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 Reportβ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. π New features to boost your workflow:
|
Replace hardcoded `/` path separators with path.join() and path.sep to fix test failures on Windows where path separators differ. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
srtaalej
left a comment
There was a problem hiding this comment.
thanks for maintaining our code health β! looks like codecov is being finicky but would be great to land this once thats resolved π« π
zimeg
left a comment
There was a problem hiding this comment.
@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 π
| const tempDir = path.join(process.cwd(), 'tmp'); | ||
| const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'check-update-')); |
There was a problem hiding this comment.
ποΈβπ¨οΈ note: Here we're avoiding a stalemate when multiple tests run at the same time. Now we instead use separate tmp directories!
| sinon.stub(childProcess, 'exec').callsFake((command, cb) => { | ||
| cb(null, { stdout: mockNPM(command), stderr: '' }); | ||
| }); |
There was a problem hiding this comment.
πΊ 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", |
There was a problem hiding this comment.
πͺ 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", |
There was a problem hiding this comment.
π note: We prefer tsx with these latest changes instead of ts-node for imports into the test:
| // Use require() so rewiremock can intercept @slack/web-api dependency | ||
| var { InstallProvider } = require('./index') as typeof import('./index'); |
There was a problem hiding this comment.
π§ͺ 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.
| 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); |
There was a problem hiding this comment.
π£οΈ note: This change is to production code to improve our tests on Windows! I added a changeset for this here in c3d1f1a.
| // Swallow unhandled rejections from internal reconnection cleanup | ||
| process.emit = (event, ...args) => { | ||
| if (event === 'unhandledRejection') return true; | ||
| return originalEmit(event, ...args); | ||
| }; |
There was a problem hiding this comment.
ποΈβπ¨οΈ note: Perhaps related to #1787 but let's continue investigation later. We added this to avoid flaky tests for now.
| 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. |
There was a problem hiding this comment.
π note: Here we're padding our possible timing for edges that might exist on Windows startup.
Summary
This PR uses the
nodetest runner for unit tests of workspace packages - #2359 πAlso removed are packages used for testing before for fewer dependencies overall:
These include kind development dependencies: πΎ β¨
@types/chai@types/mochac8chaimochamocha-junit-reportermocha-multi-reporterssource-map-supportts-nodeNotes
4820seconds to much less!Requirements