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/ and dist/
- 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:dist script that imports from dist/index.js
- Avoid
src/ aliases in these tests
- 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 pack the 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)
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.ts importing from dist/
- Add a root
test:e2e:package script using an example fixture
- Update
TESTING.md to document Distribution Testing
- Apply the same pattern to
@arkenv/*-plugin packages as needed
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:
arktype)arkenv/arktype)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:
src/anddist/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.
dist/behaves exactly as published.test:distscript that imports fromdist/index.jssrc/aliases in these tests2. Example Project Fixtures (Package-Level E2E)
Formalize
examples/as installation-level integration fixtures.pnpm packthe current workspace3. Artifact Verification (Static Analysis)
Add lightweight checks on the built files.
import/require("arktype")in main entryRelationship to Existing Testing Strategy
These tests complement, not replace, existing coverage.
Non-Goals
Implementation Plan
packages/arkenv/test/dist.test.tsimporting fromdist/test:e2e:packagescript using an example fixtureTESTING.mdto document Distribution Testing@arkenv/*-pluginpackages as needed