-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Status
Proposed
Summary
Introduce a new class of tests that validate ArkEnv’s built artifacts (dist/) and real-world installation behavior, ensuring correctness when optional peer dependencies, subpath exports, and bundling are involved.
Motivation
ArkEnv relies on:
- Optional peer dependencies (e.g.
arktype) - Bundled distribution artifacts
- Subpath exports (
arkenv/arktype) - Plugin consumers (Vite, Bun, etc.)
Certain failures only surface after bundling and outside the monorepo, but are currently invisible to our test suite, which primarily targets src/ with Vitest’s module resolution.
Concrete issues this RFC addresses:
- Path resolution mismatches between
src/anddist/ - Peer dependency masking in monorepo test environments
- Accidental eager imports of optional dependencies in built output
- Export map regressions that only affect consumers
These risks increase as we approach a production-ready v1.
Proposal
Add Distribution Integration Tests as a first-class testing category.
1. Dist-Targeted Tests
Run a subset of tests directly against the built output.
- Goal: Validate that
dist/behaves exactly as published. - Approach:
- Add a
test:distscript that imports fromdist/index.js - Avoid
src/aliases in these tests
- Add a
- Catches:
- Broken relative paths
- Incorrect subpath exports
- Runtime-only failures
2. Example Project Fixtures (Package-Level E2E)
Formalize examples/ as installation-level integration fixtures.
- Goal: Test ArkEnv as a real dependency.
- Approach:
pnpm packthe current workspace- Install into an example project
- Run the example’s entry script
- Assert on stdout/stderr
- Use cases:
- With vs without optional peers
- Framework-specific integrations (Vite, Bun, etc.)
3. Artifact Verification (Static Analysis)
Add lightweight checks on the built files.
- Goal: Enforce invariants on the published artifact.
- Checks:
- No top-level
import/require("arktype")in main entry - Optional dependencies remain lazy
- Bundle size regression detection (smoke-level)
- No top-level
Relationship to Existing Testing Strategy
| Category | Scope | Status |
|---|---|---|
| Unit Tests | Pure logic | Existing |
| Integration Tests | Validator behavior | Existing |
| Distribution Tests | Built artifact behavior | New |
| Example / Fixture Execution | Real consumer installs | New |
These tests complement, not replace, existing coverage.
Non-Goals
- Replacing source-level tests
- Introducing heavy E2E frameworks
- Testing framework internals (handled by plugin-specific suites)
Implementation Plan
- Add
packages/arkenv/test/dist.test.tsimporting fromdist/ - Add a root
test:e2e:packagescript using an example fixture - Update
TESTING.mdto document Distribution Testing - Apply the same pattern to
@arkenv/*-pluginpackages as needed