unit-testing

Guide Vitest unit test creation and maintenance for the bootc extension.

477|33|Updated Dec 19, 2023
One-click install
npx skills add https://github.com/podman-desktop/extension-bootc --skill unit-testing-podman-desktop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unit-testing
Source: https://github.com/podman-desktop/extension-bootc/tree/main/.agents/skills/unit-testing
Command: npx skills add https://github.com/podman-desktop/extension-bootc --skill unit-testing-podman-desktop

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill reduces regressions and flaky behavior by teaching you how to write consistent Vitest unit tests for the bootc extension’s backend, frontend, and shared logic.

Core Features & Use Cases

  • Vitest setup by package type: Uses Node.js environments for backend/shared and a JSDOM environment plus Svelte testing utilities for frontend components.
  • Practical mocking patterns: Shows how to mock @podman-desktop/api, RPC clients, Node.js modules, Svelte stores, and Vite path aliases so tests stay focused and deterministic.
  • Execution and coverage guidance: Provides exact commands for running tests per package, running single files, and generating lcov/text coverage outputs.

Quick Start

Run pnpm test:backend to execute backend Vitest unit tests and verify your mocked @podman-desktop/api interactions behave as expected.

Frequently Asked Questions about unit-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Vitest unit tests for Svelte components and backend packages?

Vitest unit tests require package-scoped environments: Node.js for backend and shared packages, and JSDOM with Svelte testing utilities for frontend components to ensure correct execution and behavior.

What's the best way to mock @podman-desktop/api and RPC clients in Vitest?

Mocking @podman-desktop/api and RPC clients in Vitest involves using practical mocking patterns to isolate Node.js modules, Svelte stores, and Vite path aliases so tests remain focused and deterministic.

How do I run a single Vitest spec file and generate code coverage?

Run single Vitest files and generate lcov/text coverage outputs by using exact package-scoped commands like pnpm test:backend to verify mocked API interactions and resolve failing runs.

Why do my frontend Vitest tests fail when testing Svelte UI behavior?

Frontend Vitest tests fail when the environment is incorrect; Svelte UI behavior requires a JSDOM environment setup plus specific Svelte testing utilities instead of the Node.js environment used for backend logic.

Do I need specific naming conventions for .spec.ts files in the bootc extension?

Yes, consistent test file naming for .spec.ts files is required across backend, frontend, and shared packages to guide developers in creating, maintaining, and expanding Vitest unit test coverage effectively.