Skip to content

feat(vitest): add automatic suite enforcement - #10

Closed
wscourge wants to merge 2 commits into
oniani1:masterfrom
wscourge:feat/vitest-auto-setup
Closed

feat(vitest): add automatic suite enforcement#10
wscourge wants to merge 2 commits into
oniani1:masterfrom
wscourge:feat/vitest-auto-setup

Conversation

@wscourge

Copy link
Copy Markdown

Summary

  • add a side-effectful qguard/vitest/setup entry point that installs qguard and wraps every Vitest test in an isolated query-tracking context
  • export qguardSetup from qguard/vitest for a clean setupFiles: [qguardSetup] configuration
  • fail only the offending test with the existing QueryGuardError, including configured notification dispatch and test metadata
  • cover clean tests, automatic failures, concurrent-test isolation, and user beforeEach/afterEach hooks with real nested Vitest runs
  • document automatic setup, opt-out, lifecycle boundaries, and the explicit assertion APIs

Usage

// vitest.config.ts
import { defineConfig } from 'vitest/config'
import { qguardSetup } from 'qguard/vitest'

export default defineConfig({
  test: {
    setupFiles: [qguardSetup],
  },
})

Vitest resolves setupFiles strings relative to the project root rather than through package exports. qguardSetup therefore exposes the absolute path to the new qguard/vitest/setup entry point.

The setup module deliberately installs drivers with top-level await and keeps its beforeEach hook synchronous. Entering AsyncLocalStorage after an awaited hook does not propagate the context back into Vitest's test runner.

Verification

  • typecheck passed
  • Biome passed for src/ and all new tests/fixtures
  • unit suite: 246 tests passed
  • PostgreSQL + MySQL integration suite: 15 tests passed
  • production build passed
  • packed artifact contains the setup entry point and remains under the 40 KB gate (34,118 bytes)
  • packed consumer verified against Vitest 1.0.4; repository coverage runs on Vitest 3.2.4

Closes #9

@wscourge wscourge closed this Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(vitest): add automatic setup-file enforcement

1 participant