Skip to content

chore: Replace chai with @nevware21/tripwire#369

Merged
nev21 merged 22 commits intomainfrom
copilot/remove-chai-usage
Feb 13, 2026
Merged

chore: Replace chai with @nevware21/tripwire#369
nev21 merged 22 commits intomainfrom
copilot/remove-chai-usage

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

Migrates assertion library from chai to @nevware21/tripwire using native tripwire assertions.

Changes

Dependencies:

  • Removed chai and @types/chai from all packages (shared, ts-plugin, eslint-ts-plugin)
  • Added @nevware21/tripwire (0.1.7) to all packages
  • Updated Rush shrinkwrap

Test assertions:

  • Replaced chai imports with @nevware21/tripwire in all test files
  • Replaced Node's assert imports with tripwire assertions
  • Fixed TypeScript compilation errors with arrForEach callbacks by wrapping assertions in arrow function bodies
  • Use strictEqual for primitive comparisons
  • Use deepStrictEqual for object and array comparisons throughout

Technical note

This PR uses tripwire 0.1.7, which includes a fix for deepStrictEqual to work correctly with new object instances. The fix makes tripwire's deepStrictEqual behave like Node's assert.deepStrictEqual, comparing values structurally rather than requiring exact instance identity.

All 92 tests pass.

Original prompt

This section details on the original issue you should resolve

<issue_title>chore: Remove usage of chai from the repo and use @nevware21/tripwire</issue_title>
<issue_description>Update the repo to use tripwire for the assertions, replacing all usages of chai. Use the native tripwire assertions rather than the shim.

This includes removing the following packages

  • @types/chai
  • chai

See previous review #365 for additional comments</issue_description>

Comments on the Issue (you are @copilot in this section)

@nev21 review comments on https://github.com//pull/365

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 8, 2026 22:20
Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove usage of chai and use @nevware21/tripwire chore: Replace chai with @nevware21/tripwire Feb 8, 2026
Copilot AI requested a review from nev21 February 8, 2026 22:26
Copy link
Collaborator

@nev21 nev21 left a comment

Choose a reason for hiding this comment

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

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);

Copy link
Contributor Author

Copilot AI commented Feb 8, 2026

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

I've attempted to use deepStrictEqual for the in-memory operations in utils.test.ts, but the tests fail with tripwire's implementation even though they passed with Node's assert.deepStrictEqual originally.

The issue is that tripwire's deepStrictEqual appears to require the exact same object instance, which fails for functions like deepMerge and mergeOptions that return new objects via objAssign({}, ...).

Could you clarify: should I keep deepEqual for these tests, or is there a different approach I should use to make deepStrictEqual work with tripwire for new object instances?

Copilot AI requested a review from nev21 February 8, 2026 22:39
@nev21 nev21 marked this pull request as ready for review February 8, 2026 22:48
@nev21 nev21 requested review from a team as code owners February 8, 2026 22:48
Copilot AI review requested due to automatic review settings February 8, 2026 22:48
@nev21 nev21 enabled auto-merge (squash) February 8, 2026 22:49
@nev21
Copy link
Collaborator

nev21 commented Feb 8, 2026

@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

Copy link
Contributor Author

Copilot AI commented Feb 8, 2026

@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 deepStrictEqual has stricter instance checking than Node's assert

Details:

  • Node's assert.deepStrictEqual passes when comparing structurally identical objects created via objAssign({}, ...)
  • Tripwire's assert.deepStrictEqual fails on the same comparisons, requiring exact instance identity
  • This affects tests for functions like deepMerge and mergeOptions that return new object instances

Example:

// This passes with Node's assert but fails with tripwire
const result = objAssign({}, { a: 1 });
assert.deepStrictEqual(result, { a: 1 }); // Fails: different instances

Workaround: Use deepEqual instead of deepStrictEqual for new object instances.

Could you create the issue, or should I document this differently?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 chai and @types/chai from package devDependencies and Rush shrinkwrap.
  • Added @nevware21/tripwire (>= 0.1.6 < 2.x) to all packages and updated common/config/rush/npm-shrinkwrap.json.
  • Updated test files to import Tripwire assertions and replaced deepStrictEqual usages with deepEqual.

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

Copilot AI requested a review from nev21 February 10, 2026 16:44
Copy link
Collaborator

@nev21 nev21 left a comment

Choose a reason for hiding this comment

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

@copilot still missing some reasons for changing the assertion type

Copilot AI and others added 2 commits February 11, 2026 16:46
…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>
nevware21-bot and others added 2 commits February 11, 2026 08:48
…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>
Copy link
Contributor Author

Copilot AI commented Feb 11, 2026

@copilot still missing some reasons for changing the assertion type

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.

Copy link
Collaborator

@nev21 nev21 left a comment

Choose a reason for hiding this comment

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

@copilot not that v 0.1.7 of tripwire is now released with the fix recreate this PR using the deepStrictEqual, so the only code change required "should" be the import to change.

Copilot AI and others added 2 commits February 13, 2026 02:03
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>
Copy link
Contributor Author

Copilot AI commented Feb 13, 2026

@copilot not that v 0.1.7 of tripwire is now released with the fix recreate this PR using the deepStrictEqual, so the only code change required "should" be the import to change.

Updated to tripwire 0.1.7 in commit 41fe8d2. Replaced all deepEqual with deepStrictEqual and removed all explanatory comments. The fix in 0.1.7 makes deepStrictEqual work correctly with new object instances, so the tests now use deepStrictEqual throughout as originally intended. All 92 tests pass.

Copilot AI requested a review from nev21 February 13, 2026 02:04
@nev21 nev21 enabled auto-merge (squash) February 13, 2026 05:57
Copy link
Collaborator

@nev21 nev21 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@nev21 nev21 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@nevware21-bot nevware21-bot left a comment

Choose a reason for hiding this comment

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

Approved by nevware21-bot

@nev21 nev21 merged commit 94f4023 into main Feb 13, 2026
7 checks passed
@nev21 nev21 deleted the copilot/remove-chai-usage branch February 13, 2026 17:43
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.

chore: Remove usage of chai from the repo and use @nevware21/tripwire

3 participants