Testing in CompendiumUI¶
This project uses vitest for automated testing.
Running Tests¶
To run the full test suite:
Test Suite Overview¶
As of the latest update, the test suite consists of 6 test files with 72 tests in total.
Test Files¶
translation.test.ts: Verifies theTranslationServicelogic.- Tests support for
window.ai.translator(Chrome Experimental). - Tests fallback to
window.Translator. - Tests graceful handling of missing APIs and errors.
- Tests support for
accessibility.test.ts: Checks for accessibility compliance (ARIA attributes, keyboard navigation, etc.).layout.test.ts: Verifies layout consistency and responsiveness.navigation.test.ts: Tests the navigation menu, sidenav generation, and link handling.security.test.ts: Checks for security best practices (e.g., input sanitization, linking to external sites).utilities.test.ts: Tests utility functions (e.g., helpers, formatting).
Recent Changes¶
- TranslationService: The
TranslationServiceclass is now exported fromscript.tsto allow for direct unit testing. - Mocking: Tests use
vi.fn()and mock objects forwindowAPIs (likelocalStorageandtranslator) to ensure isolation and reliability.