This document outlines improvements made to the testing infrastructure.Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Summary of Changes
P0: Critical Fixes (Completed)
- ✅ Fixed Playwright baseURL - Changed from
http://localhost:8080tohttp://localhost:4173to match the preview server - ✅ Created unified TestProviders wrapper - New
tests/utils/providers.tsxprovides a single wrapper for all React hook tests - ✅ Added
test:e2e/test:e2e:ui/test:quickscripts - 2026-04-18 - ✅ Repointed HR hook test imports to current subfolder paths - 2026-04-18 (Phase 1 of dev/test stability plan)
- ✅ Aliased Deno-only
npm:@sentry/denoto a Node shim for Vitest - 2026-04-18 (tests/mocks/deno-sentry-shim.ts) - ✅ TestProviders now wraps in MemoryRouter with
noRouteropt-out for tests that wrap their own router - ✅ Migrated 22+ failing component/hook tests to TestProviders + provider-wrapped renders - 2026-04-18
- ✅ Eliminated all
Failed Suites(SKIP_SUPABASE_TESTS=true npm run test:unitshows0 failed)
P1: High Priority Improvements (Completed)
- ✅ Module-specific cleanup utilities - Split cleanup logic into
tests/utils/cleanup/ - ✅ Updated test templates -
UNIT_TEST_TEMPLATE.tsuses new TestProviders wrapper - ✅ Coverage thresholds raised to 40% statements/lines/functions, 35% branches
- ✅ Vitest pool switched to
threadswith boundedmaxWorkers- 2026-04-18 (vitest.config.ts) - ⏳ CI-safe test distinction - documentation present; per-project split (
unit/integration/rls) deferred until shared-mock cleanup audit completes (anisolate: falsetrial revealed ~200 cross-test contamination failures) - ⏳ Standardize test organization - documentation present; in-flight
P2: Medium Priority
- ✅ Module-specific test scripts -
test:e2e:{auth,hr,fa,ce,fw,gr,platform},test:e2e:smoke,test:rls:smoke, etc. - ⏳ Vitest projects split (unit/integration/rls) - Deferred (see P1#5).
- ⏳ Supabase types split by schema - Tracked separately; the 100k-line generated types file is the dominant
tsccost.
New Files Created
Test Utilities
-
tests/utils/providers.tsx- Unified wrapper component with QueryClientProvider and OrganizationProvider
- Replaces manual QueryClient setup in every test
- Usage:
import { TestProviders, wrapper } from '@/tests/utils/providers';
-
tests/utils/cleanup/directorypf-cleanup.ts- Platform Foundation cleanuphr-cleanup.ts- Human Resources cleanupfa-cleanup.ts- Finance & Accounting cleanupfw-cleanup.ts- Forms & Workflow cleanupindex.ts- Unified export for all cleanup functions
Documentation
docs/testing/TESTING_IMPROVEMENTS.md(this file)tests/utils/cleanup/README.md- Cleanup utilities documentation
Manual Changes Required
Due to security hooks protecting certain configuration files, the following changes need to be made manually:1. Add E2E Test Scripts to package.json
Add these scripts after "test:rls":
2. Update vitest.config.ts
Enable Parallel Execution for Unit Tests
Change:Increase Coverage Thresholds
Change:Add Different Timeouts for Different Test Types
Consider adding test-specific timeouts:Migration Guide
For Existing Tests
1. Update Hook Tests to Use TestProviders
Before:2. Update Component Tests to Use TestProviders
Before:3. Update Cleanup in tests/setup.ts
Before:
Test Organization Standards
Naming Conventions
- RLS Tests:
{core}-{table}.rls.test.ts(e.g.,hr-employees.rls.test.ts) - Unit Tests:
{core}/{feature}.test.ts(e.g.,hr/useEmployees.test.ts) - Integration Tests:
{core}/{workflow}-workflow.test.ts(e.g.,hr/onboarding-workflow.test.ts) - E2E Tests:
{core}/{feature}.spec.ts(e.g.,hr/employee-management.spec.ts)
Directory Structure
Next Steps
-
Manual Configuration Updates
- Update
package.jsonwith new test scripts - Update
vitest.config.tswith parallel execution and higher coverage thresholds
- Update
-
Migrate Existing Tests
- Update all hook tests to use
wrapperfrom@/tests/utils/providers - Update component tests to use
TestProviders - Refactor
tests/setup.tsto use module-specific cleanup utilities
- Update all hook tests to use
-
Fix Failing Tests
- Address 155+ QueryClient provider failures
- Fix 479 currently failing tests
- Reduce 2,310 skipped tests (43% of suite)
-
Documentation
- Update
docs/testing/index.mdwith new patterns - Update
.cursor/agents/test-generator.mdto use new patterns - Create migration checklist for team
- Update
Metrics to Track
| Metric | Current | Target | Status |
|---|---|---|---|
| Skip rate | 43% | <5% | ⏳ In Progress |
| Pass rate | 84.5% | >95% | ⏳ In Progress |
| Coverage threshold | 15-20% | 40% | ⏳ Pending Config Update |
| Test duration | 17 min | <10 min | ⏳ Pending Parallel Execution |
| Setup file size | 894 lines | <200 lines/file | ✅ Completed |
| Failed tests | 479 | <50 | ⏳ In Progress |
References
- Testing Infrastructure Review Plan
- Test Utilities README
- Cleanup Utilities README
- Test Templates