managarten/packages/test-config
Till JS e974761e8a chore(workspace): unify vitest to ^4.1.2 across all packages
The lockfile had grown five (!) different vitest versions over time:
1.6.1, 2.1.9, 3.2.4, 4.1.2 and 4.1.3 — pulled in by various
packages that pinned outdated majors. The mismatch produced the
classic "createDOMElementFilter not found" startup crash because
hoisted @vitest/utils@3.x was loaded by the nested @vitest/runner@4.x.

Bumped every package.json that pinned an old vitest:
- apps/manavoxel/apps/web      (^4.1.0 → ^4.1.2)
- apps/matrix/apps/web         (^4.1.0 → ^4.1.2)
- apps/memoro/apps/server      (^3.0.0 → ^4.1.2)
- apps/nutriphi/packages/shared (^2.1.8 → ^4.1.2)
- packages/qr-export           (^3.0.5 → ^4.1.2)
- packages/shared-llm          (^2.0.0 → ^4.1.2)
- packages/shared-storage      (^4.1.0 → ^4.1.2)
- packages/spiral-db           (^1.6.1 → ^4.1.2)
- packages/test-config         (^3.0.0 → ^4.1.2)
- packages/wallpaper-generator (^3.0.5 → ^4.1.2)

After a clean pnpm-lock.yaml regenerate, every @vitest/* sub-package
resolves to a single version (4.1.3, picked by semver) — no more
duplicates between hoisted and nested node_modules.

Verified by running:
  pnpm --filter @mana/web vitest run src/lib/data/sync.test.ts
  → 20/20 tests passing in 217ms
  pnpm --filter @mana/web vitest run src/lib/data/time-blocks/recurrence.test.ts
  → 19/19 tests passing in 198ms

Pre-existing test failures in base-client.test.ts (German error
strings vs english assertions), dashboard.test.ts (widget count
drift), and content/help/index.test.ts (svelte-i18n locale not
initialised in test env) are unrelated and tracked separately.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 13:58:29 +02:00
..
jest.config.backend.js feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
jest.config.mobile.js feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
package.json chore(workspace): unify vitest to ^4.1.2 across all packages 2026-04-07 13:58:29 +02:00
playwright.config.base.ts feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
README.md chore: complete ManaCore → Mana rename (docs, go modules, plists, images) 2026-04-07 12:26:10 +02:00
tsconfig.json first implementation 2025-11-27 17:26:18 +01:00
vitest.config.base.ts feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
vitest.config.svelte.ts feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00

@mana/test-config

Shared test configurations for all projects in the Mana monorepo.

Available Configurations

Jest Configuration for NestJS Backends

// jest.config.js
const baseConfig = require('@mana/test-config/jest-backend');

module.exports = {
	...baseConfig,
	// Your project-specific overrides
};

Jest Configuration for React Native Mobile

// jest.config.js
module.exports = {
	preset: '@mana/test-config/jest-mobile',
	// Your project-specific overrides
};

Vitest Configuration for Shared Packages

// vitest.config.ts
import { defineConfig, mergeConfig } from 'vitest/config';
import baseConfig from '@mana/test-config/vitest-base';

export default mergeConfig(
	baseConfig,
	defineConfig({
		// Your project-specific overrides
	})
);

Vitest Configuration for SvelteKit Web Apps

// vitest.config.ts
import { defineConfig, mergeConfig } from 'vitest/config';
import svelteConfig from '@mana/test-config/vitest-svelte';
import { sveltekit } from '@sveltejs/kit/vite';

export default mergeConfig(
	svelteConfig,
	defineConfig({
		plugins: [sveltekit()],
		// Your project-specific overrides
	})
);

Playwright Configuration for E2E Tests

// playwright.config.ts
import { defineConfig } from '@playwright/test';
import baseConfig from '@mana/test-config/playwright';

export default defineConfig({
	...baseConfig,
	use: {
		...baseConfig.use,
		baseURL: 'http://localhost:5173',
	},
	// Your project-specific overrides
});

Features

Common Settings Across All Configs

  • Coverage Thresholds: 80% for lines, functions, branches, statements
  • Mock Management: Auto-clear, restore, and reset mocks between tests
  • Timeout: 10s default for tests
  • Verbose Output: In CI environments
  • Error Handling: Fail on deprecated APIs

NestJS Backend Config

  • TypeScript support via ts-jest
  • Automatic exclusion of modules, DTOs, entities
  • Module path aliases support
  • Coverage collection from source files

React Native Mobile Config

  • jest-expo preset
  • Transform ignore patterns for React Native modules
  • Support for @mana packages
  • Coverage from src/ and app/ directories

Vitest Configs

  • Modern, fast test runner
  • Coverage via v8
  • ESM support
  • Global test APIs (describe, it, expect)

Playwright Config

  • Multi-browser testing (Chromium, Firefox, WebKit)
  • Mobile viewport testing
  • Built-in retry logic
  • Video/screenshot on failure
  • Auto-start web server

Adding to Your Project

  1. Install peer dependencies:
# For NestJS backend
pnpm add -D jest ts-jest @types/jest

# For React Native mobile
pnpm add -D jest jest-expo @testing-library/react-native

# For SvelteKit web
pnpm add -D vitest @vitest/coverage-v8 jsdom

# For E2E tests
pnpm add -D @playwright/test
  1. Create config file in your project root (see examples above)

  2. Add test scripts to package.json:

{
	"scripts": {
		"test": "jest", // or "vitest run"
		"test:watch": "jest --watch", // or "vitest"
		"test:cov": "jest --coverage", // or "vitest run --coverage"
		"test:e2e": "playwright test"
	}
}

Customization

Each config can be extended with project-specific settings:

// Override coverage thresholds
export default mergeConfig(baseConfig, {
	test: {
		coverage: {
			thresholds: {
				lines: 90, // More strict for critical packages
			},
		},
	},
});