Running Tests
Analog supports Vitest for running unit tests.
Vitest Features
Vitest supports many features:
- A Jest-compatible API.
- Supports Vite's config, transforms, resolvers, and plugins.
- Smart & instant watch mode.
- TypeScript support.
- Jest-compatible snapshots.
- jsdom for DOM mocking.
- In-source testing.
- And more ...
Running Unit Tests
To run unit tests, use the test command:
- npm
- Yarn
- pnpm
npm run test
yarn test
pnpm run test
You can also add Vitest to your existing project.
Known limitations
- 
Only globals are patched with Zone.js. This means, that if you import it,describeetc fromvitestdirectly, you won't be able to runfakeAsync. Instead, use the functions (it,describeetc. the way you used to do in Jest/Jasmine – without any imports of these functions in the test file).
- 
vmThreadsis used. This can lead to potential memory leaks and is used as a default to provide an environment closer to the Jest with JSDOM. More details you can read here.To change that – adjust your vite.config.mtsexport default defineConfig(({ mode }) => {
 return {
 test: {
 pool: 'threads', // add this property
 },
 };
 });