Files
meshtastic-web/src/__mocks__
480ca46a95 chore: lint/format all files (#604)
* chore: lint/format all files

* Fix config sidebar button state (#602)

* chore: Update deno.lock version and add Radix UI slider component (#601)

* fix: improve how table addresses even/odd rows

---------

Co-authored-by: philon- <philon-@users.noreply.github.com>
Co-authored-by: Kamil Dzieniszewski <kamil.dzieniszewski@gmail.com>
2025-05-04 15:55:04 -04:00
..
2025-03-09 12:57:37 -04:00

Mocks Directory

This directory contains mock implementations used by Vitest for testing.

Structure

The directory structure mirrors the actual project structure to make mocking more intuitive:

__mocks__/
├── components/
│   └── UI/
│       ├── Dialog.tsx
│       ├── Button.tsx
│       ├── Checkbox.tsx
│       └── ...
├── core/
│   └── ...
└── ...

Auto-mocking

Vitest will automatically use the mock files in this directory when the corresponding module is imported in tests. For example, when a test imports @components/UI/Dialog.tsx, Vitest will use __mocks__/components/UI/Dialog.tsx instead.

Creating New Mocks

To create a new mock:

  1. Create a file in the same relative path as the original module
  2. Export the mocked functionality with the same names as the original
  3. Add a vi.mock() statement to vitest.setup.ts if needed

Mock Guidelines

  • Keep mocks as simple as possible
  • Use data-testid attributes for easy querying in tests
  • Implement just enough functionality to test the component
  • Use TypeScript types to ensure compatibility with the original module