Skip to content

test: migrate all tests from mocha/chai to vitest#638

Open
douglance wants to merge 10 commits intomainfrom
chore/vitest-unit-tests
Open

test: migrate all tests from mocha/chai to vitest#638
douglance wants to merge 10 commits intomainfrom
chore/vitest-unit-tests

Conversation

@douglance
Copy link
Copy Markdown
Contributor

Summary

  • Migrate all integration, fork, and remaining unit tests from mocha/chai to vitest assertions
  • Remove chai, @types/chai, mocha, @types/mocha, eslint-plugin-mocha, nyc dependencies
  • Delete .mocharc.json config
  • Update packages/sdk/package.json test scripts to use vitest
  • Add vitest imports to mochaExtensions.ts

Test plan

  • yarn test:unit passes (61 tests across 10 files)
  • CI passes
  • Integration tests run correctly in CI environment

Migrate all integration, fork, and remaining unit tests to vitest.
Remove chai, mocha, nyc, and related dependencies and configs.
@cla-bot cla-bot Bot added the cla-signed label Apr 1, 2026
- beforeEach('skipIfMainnet', fn) → beforeEach(fn) (vitest doesn't support description arg)
- before(fn) → beforeAll(fn) (vitest uses beforeAll, not before)
- Add hookTimeout (60s) for long-running beforeAll hooks
- Add allowEmpty for suites where all tests are conditionally skipped
- Add --fileParallelism=false for integration tests (shared blockchain state)
- Replace mocha this.skip() with vitest context.skip() in l1l3Bridger tests
- Await fire-and-forget .then() in customerc20 to prevent unhandled rejection
This assertion was always a fire-and-forget .then() under mocha that
silently swallowed failures. Removing it since it was never effective.
The deposit test used parseEther('2') (always 2e18) regardless of the
token's native decimals. Since EthBridger.deposit() passes the amount
directly to depositERC20(uint256) without scaling, this caused failures
for non-18 decimal tokens (16-decimal: exceeds balance, 20-decimal:
value mismatch on L2). These tests were never actually running under
mocha because async describe callbacks aren't awaited.
@douglance douglance force-pushed the chore/vitest-unit-tests branch from 3142fb1 to 6ad363d Compare April 6, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant