Commit 7cded72
committed
refactor(test): swap chai assertions for vitest's native expect
Replaces ~3,400 chai assertions across 170 test files with vitest's native
`expect` matchers. Unlocks vitest's diff rendering, snapshot testing, typed
matchers, and drops chai/chai-as-promised devDeps from pure-vitest packages.
## Conversions (mechanical, per a shared mapping)
- `to.equal` → `toBe`, `to.deep.equal` → `toEqual`
- `to.be.true/false/null/undefined` → `toBe(true/false)`, `toBeNull`, `toBeUndefined`
- `to.exist` → `toBeDefined` (each site verified — chai's .exist also checks truthy)
- `to.have.length(Of)(n)` → `toHaveLength(n)`
- `to.have.property(p[, v])` → `toHaveProperty(p[, v])`
- `to.match(/r/)` → `toMatch(/r/)`, `to.include`/`to.contain` → `toContain`
- `to.deep.include` → `toContainEqual` (arrays) or `toMatchObject` (objects)
- `to.throw(msg)` → `toThrow(msg)`
- `to.be.{greaterThan,at.least,at.most}` → `toBeGreaterThan(OrEqual)`, etc
- `to.be.closeTo(x, delta)` → `toBeCloseTo(x, precision)` (2 sites; delta→precision)
- `to.be.oneOf([...])` → swap sides: `expect([...]).toContain(x)`
- `to.be.empty` → `toHaveLength(0)`
- `to.be.a('type')` → `toBeTypeOf('type')`
- `to.be.instanceOf(C)` → `toBeInstanceOf(C)`
- `to.have.members(arr)` → `Set` equality
- `to.include.members(arr)` → `expect.arrayContaining(arr)`
## chai-as-promised
- `await expect(p).to.be.rejectedWith(msg)` → `await expect(p).rejects.toThrow(msg)`
- 4× chained `rejectedWith(Err).and.eventually.have.property(...)` in
http-registry-server restructured into `rejects.toThrow(...)` + `try/catch`
with `expect(err).toBeInstanceOf(...)` + `expect(err).toHaveProperty(...)`
- `.should.eventually.be.rejectedWith(...)` (1 site in infra/warp-configs) →
`.rejects.toThrow(...)`
- All `chai.use(chaiAsPromised)` and `import chaiAsPromised` lines removed
- Shared root `vitest.setup.ts` deleted (only purpose was chai-as-promised
registration); `setupFiles` references removed from 19 per-package configs
## Assertion messages
vitest matchers don't accept a 2nd-arg message; `expect(val, msg)` does.
Moved messages from `.toBeGreaterThanOrEqual(n, msg)` to
`expect(x, msg).toBeGreaterThanOrEqual(n)` in sdk multisigIsm, rebalancer-sim
full-simulation, infra gitleaks tests.
oxlint `jest/valid-expect` disabled for test files since vitest supports the
2-arg expect signature that jest doesn't. Also disabled `no-conditional-expect`,
`require-to-throw-message`, `no-standalone-expect` — these jest plugin rules
are style-level, don't apply to vitest idioms in this codebase, and start
firing because `expect().toBe()` now looks like jest syntax.
## expect.fail()
22 occurrences in rebalancer LiFiBridge.test.ts (inside try/catch blocks),
plus a handful elsewhere → `throw new Error(msg)`. In .then() callbacks
(cli create-altvm-signers.test.ts) rendered as
`.then(() => { throw new Error(msg) })`.
## devDeps cleanup
Pure-vitest packages had `chai`, `chai-as-promised`, `@types/chai`,
`@types/chai-as-promised`, `@types/sinon-chai` removed from devDependencies:
ccip-server, deploy-sdk, fee-quoting, github-proxy, http-registry-server,
keyfunder, metrics, provider-sdk, rebalancer-sim, utils, warp-monitor.
Hybrid packages KEEP chai devDeps for hardhat/e2e suites:
cli, infra, rebalancer, relayer, sdk, plus starknet-sdk/svm-sdk/tron-sdk/
radix-sdk/cosmos-sdk/aleo-sdk/helloworld whose e2e or hardhat paths stay on
mocha.
Root `package.json` drops chai/chai-as-promised/vitest devDeps (only added
in the previous PR to support the shared setup file).
Catalog: `chai`, `chai-as-promised`, `sinon` entries retained — still used
by hardhat/e2e test paths across the monorepo.
## Tests
~2,100 tests green across the migrated vitest suites. `pnpm build` at the
root passes. `pnpm format:check` + `pnpm lint` pass. Full `pnpm test:ci`
deferred to CI.1 parent 5ef7a07 commit 7cded72
203 files changed
Lines changed: 3794 additions & 4034 deletions
File tree
- typescript
- ccip-server
- tests/services
- cli/src
- commands
- config
- context/strategies/chain
- deploy
- status
- tests
- context
- ethereum
- utils
- deploy-sdk
- src
- core
- hook
- warp
- fee-quoting
- test
- routes
- services
- github-proxy
- http-registry-server
- test
- middleware
- routes
- services
- infra
- test
- keyfunder
- src
- config
- core
- metrics
- metrics
- src
- provider-sdk
- src
- radix-sdk
- src
- mailbox
- utils
- rebalancer-sim
- test
- integration
- scenarios
- rebalancer
- src
- bridges
- config
- core
- factories
- strategy
- tracking
- store
- utils
- relayer
- src
- fs
- metadata
- sdk
- src
- app
- consts
- core
- adapters
- deploy
- verify
- fee
- gas
- adapters
- hook
- ism
- metadata
- middleware/account
- predicate
- providers
- SmartProvider
- runtime
- transactions
- submitter
- builder
- ethersV5
- quoted-calls
- router
- signers/svm
- token
- adapters
- utils
- warp
- starknet-sdk
- src
- clients
- hook
- ism
- mailbox
- validator-announce
- warp
- svm-sdk
- src/tests
- tron-sdk
- src/ethers
- utils
- src
- fs
- warp-monitor
- src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
126 | 130 | | |
127 | 131 | | |
128 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | 29 | | |
32 | 30 | | |
33 | 31 | | |
| |||
36 | 34 | | |
37 | 35 | | |
38 | 36 | | |
39 | | - | |
40 | | - | |
| 37 | + | |
41 | 38 | | |
42 | 39 | | |
43 | 40 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | 52 | | |
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
60 | | - | |
61 | 59 | | |
62 | 60 | | |
63 | 61 | | |
| |||
0 commit comments