chore: Replace chai with @nevware21/tripwire#369
Conversation
Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
nev21
left a comment
There was a problem hiding this comment.
You should continue to use deepStrictEqual except for when the content is reloaded from a file which will cause the values to be different objects
assert.deepStrictEqual(result[0].tsConfig, expectedContent);
assert.deepEqual(result[0].tsConfig, expectedContent);
I've attempted to use The issue is that tripwire's Could you clarify: should I keep |
|
@copilot create an issue on @nevware21/tripwire with the findings of the differences between node assert so that the documentation and compatibility can be defined |
I don't have the ability to create issues on external repositories. However, here are the findings that should be reported: Issue: tripwire's Details:
Example: // This passes with Node's assert but fails with tripwire
const result = objAssign({}, { a: 1 });
assert.deepStrictEqual(result, { a: 1 }); // Fails: different instancesWorkaround: Use Could you create the issue, or should I document this differently? |
There was a problem hiding this comment.
Pull request overview
This PR migrates the repo’s test assertions from chai / Node’s built-in assert to @nevware21/tripwire, updating package dependencies and aligning test assertions to Tripwire’s APIs.
Changes:
- Removed
chaiand@types/chaifrom package devDependencies and Rush shrinkwrap. - Added
@nevware21/tripwire(>= 0.1.6 < 2.x) to all packages and updatedcommon/config/rush/npm-shrinkwrap.json. - Updated test files to import Tripwire assertions and replaced
deepStrictEqualusages withdeepEqual.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
ts-plugin/test/src/TypeScript.test.ts |
Switches test assertions import to Tripwire. |
ts-plugin/package.json |
Replaces chai devDependencies with @nevware21/tripwire. |
shared/test/src/utils.test.ts |
Migrates assertions to Tripwire and replaces deep strict comparisons with deepEqual. |
shared/test/src/tsConfigDetails.test.ts |
Migrates assertions to Tripwire and updates deep comparisons. |
shared/test/src/random.test.ts |
Switches from chai assertions import to Tripwire. |
shared/test/src/fileHelper.test.ts |
Switches from chai assertions import to Tripwire and updates deep comparisons. |
shared/package.json |
Replaces chai devDependencies with @nevware21/tripwire. |
eslint-ts-plugin/test/src/ESLintRunner.test.ts |
Switches test assertions import to Tripwire. |
eslint-ts-plugin/package.json |
Replaces chai devDependencies with @nevware21/tripwire. |
common/config/rush/npm-shrinkwrap.json |
Removes chai from shrinkwrap and adds Tripwire + its resolved dependency entries. |
Files not reviewed (1)
- common/config/rush/npm-shrinkwrap.json: Language not supported
…tests Added explanatory comments to lines 427 and 473 where deepEqual assertions test the second result in tests that check multiple results. Each deepEqual now has its own comment explaining why deepStrictEqual cannot be used, even when testing multiple results from the same function call. Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
…ertions Added explanatory comments before each deepEqual assertion that was previously sharing a comment with another assertion. Now every single deepEqual has its own dedicated comment immediately before it explaining why deepStrictEqual cannot be used. This includes: - Lines 138, 188, 238, 290, 343 in tsConfigDetails.test.ts (second assertions in multi-result tests) - Line 534 in tsConfigDetails.test.ts (second array assertion) Total: 40 deepEqual assertions, 40 individual explanatory comments. Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
Fixed in b2c4570. Added individual explanatory comments for the 6 remaining deepEqual assertions that were sharing comments with other assertions (lines 138, 188, 238, 290, 343, 534). Every single deepEqual assertion now has its own dedicated comment immediately before it. |
Tripwire 0.1.7 has been released with a fix for deepStrictEqual to work correctly with new object instances. This allows us to: - Update to @nevware21/tripwire 0.1.7 - Replace all deepEqual with deepStrictEqual (as originally intended) - Remove all explanatory comments about why deepEqual was needed The fix in tripwire 0.1.7 makes deepStrictEqual behave like Node's assert.deepStrictEqual, comparing values structurally rather than requiring exact instance identity. All 92 tests pass. Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
Updated to tripwire 0.1.7 in commit 41fe8d2. Replaced all |
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
Migrates assertion library from chai to @nevware21/tripwire using native tripwire assertions.
Changes
Dependencies:
chaiand@types/chaifrom all packages (shared, ts-plugin, eslint-ts-plugin)@nevware21/tripwire(0.1.7) to all packagesTest assertions:
chaiimports with@nevware21/tripwirein all test filesassertimports with tripwire assertionsstrictEqualfor primitive comparisonsdeepStrictEqualfor object and array comparisons throughoutTechnical note
This PR uses tripwire 0.1.7, which includes a fix for
deepStrictEqualto work correctly with new object instances. The fix makes tripwire'sdeepStrictEqualbehave like Node'sassert.deepStrictEqual, comparing values structurally rather than requiring exact instance identity.All 92 tests pass.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.