Skip to content

feat: add Vitest test suite with store and utility tests#10

Merged
Nic-dorman merged 4 commits intomainfrom
feat/vitest-setup
Apr 8, 2026
Merged

feat: add Vitest test suite with store and utility tests#10
Nic-dorman merged 4 commits intomainfrom
feat/vitest-setup

Conversation

@Nic-dorman
Copy link
Copy Markdown
Contributor

Summary

Set up Vitest with @nuxt/test-utils for unit and integration testing. Includes mock infrastructure and initial test coverage for the most critical frontend logic.

What's included

File Purpose
vitest.config.ts Nuxt test environment with happy-dom
tests/mocks/tauri.ts Mock for @tauri-apps/api/core invoke() — lets tests simulate Tauri command responses
tests/mocks/appkit.ts Mocks for WalletConnect/AppKit/wagmi (CommonJS modules that break in ESM test env)
tests/stores/settings.test.ts Config load/save, devnet manifest detection, Sepolia detection
tests/stores/nodes.test.ts Daemon connection flow, SSE event handling, status getters
tests/utils/wallet-config.test.ts Chain ID selection, token/vault address overrides per network mode

Test coverage

19 tests across 3 suites:

  • Settings store (6 tests): loads config from backend, handles corrupt config gracefully, activates devnet mode from manifest, detects Sepolia from RPC URL, stays in production mode without manifest, persists config changes
  • Nodes store (6 tests): connects to daemon on startup, updates daemon URL on port change, sets disconnected when daemon unavailable, handles SSE node events, handles crash events, counts nodes by status
  • Wallet config (7 tests): returns correct chain ID for mainnet/Sepolia/Anvil, returns correct token and vault addresses with devnet overrides

How to run

npm test          # watch mode
npm run test:run  # single run

Test plan

  • All 19 tests pass locally
  • Tauri invoke mock correctly intercepts all store commands
  • AppKit/WalletConnect mocked to avoid CommonJS import errors

🤖 Generated with Claude Code

Nic-dorman and others added 4 commits April 8, 2026 12:51
Set up Vitest with @nuxt/test-utils and happy-dom for unit/integration
testing. Includes mock infrastructure for Tauri invoke commands and
WalletConnect/AppKit modules.

Tests cover:
- settings store: config load/save, devnet manifest detection, Sepolia
  detection from RPC URL
- nodes store: daemon connection flow, SSE event handling, status
  getters, disconnection recovery
- wallet-config: chain ID selection (mainnet/Sepolia/Anvil), token and
  vault address overrides in devnet mode

19 tests across 3 suites.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Run on every push to main and on pull requests:

Frontend:
- nuxi typecheck (vue-tsc)
- vitest run

Rust (parallel matrix):
- cargo fmt --check
- cargo clippy -D warnings
- cargo check

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Nic-dorman Nic-dorman merged commit da044d4 into main Apr 8, 2026
4 checks passed
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.

1 participant