Framework Version: 2.3.0 Last Updated: 2025-10-26 Status: Production Ready
This document provides a comprehensive overview of all implemented features in the Zig Test Framework.
- Status: Production Ready
- Features:
- Automatic
*.test.zigfile discovery - Recursive directory scanning
- Configurable file patterns
- Test file compilation and execution
- Programmatic test registration
- Test registry management
- Automatic
- Status: Production Ready
- Features:
describe()blocks for test organization- Nested test suites (unlimited depth)
- Suite-level configuration
- Parent-child hook inheritance
- Suite skipping (
describeSkip) - Suite focusing (
describeOnly) - Suite timeout configuration
- Status: Production Ready
- Features:
it()andtest_()test registration- Test status tracking (pending, running, passed, failed, skipped)
- Test execution timing
- Test skipping (
itSkip) - Test focusing (
itOnly) - Test timeout per-test configuration
- Sync and async test types
- Status: Production Ready
- Features:
expect()API with fluent chaining- Negation support (
.not()) - Basic Matchers:
toBe()- EqualitytoBeTruthy()/toBeFalsy()- Boolean checkstoBeNull()/toBeDefined()- Optional checks
- Comparison Matchers:
toBeGreaterThan()/toBeGreaterThanOrEqual()toBeLessThan()/toBeLessThanOrEqual()
- String Matchers:
toContain()- Substring checktoStartWith()/toEndWith()- Prefix/suffixtoHaveLength()- Length check
- Error Matchers:
toThrow()- Any errortoThrowError()- Specific error
- Advanced Matchers:
toBeCloseTo()- Floating-point comparisontoBeNaN()- NaN checktoBeInfinite()- Infinity check
- Array Matchers:
toHaveLength()- Array lengthtoContain()- Element presencetoContainAll()- Multiple elements
- Struct Matchers:
toHaveField()- Field value check
- Status: Production Ready
- Features:
beforeAll()- Runs once before all tests in suiteafterAll()- Runs once after all tests in suitebeforeEach()- Runs before each testafterEach()- Runs after each test- Hook inheritance from parent suites
- Async hook support
- Hook timeout handling
- Error propagation from hooks
- Status: Production Ready (v2.2.0)
- Module:
src/async_test.zig - Features:
- Async test detection and registration
- Thread-based async execution
- Sequential execution mode
- Concurrent execution mode (configurable max concurrent)
- Async test timeout handling
- Async error capture and reporting
- Async hooks (beforeAll, afterAll, beforeEach, afterEach)
- Mixed sync/async test support
- Result aggregation and statistics
- API:
itAsync()- Register async testitAsyncTimeout()- Async test with custom timeoutitAsyncSkip()/itAsyncOnly()- Skip/focus async testsAsyncTestExecutor- Advanced execution controlAsyncHooksManager- Async hooks management
- Documentation:
ASYNC_TEST_COMPLETE.md - Examples:
examples/async_tests.zig(8 scenarios) - Tests: 6 unit tests (all passing)
- Status: Production Ready (v2.3.0)
- Module:
src/timeout.zig - Features:
- Global timeout configuration
- Per-test timeout (
itTimeout) - Per-suite timeout (
describeTimeout) - Timeout priority system (test > suite > global)
- Timeout detection and monitoring
- Background monitoring thread
- Timeout extension API
- Grace period support
- Thread-safe timeout tracking
- Timeout error reporting with detailed messages
- API:
itTimeout()- Register test with timeoutdescribeTimeout()- Create suite with timeoutTimeoutContext- Manual timeout controlTimeoutEnforcer- Global timeout monitoringSuiteTimeoutTracker- Suite-level trackingGlobalTimeoutConfig- Global configuration
- Documentation:
TIMEOUT_COMPLETE.md - Examples:
examples/timeout_examples.zig(10 scenarios) - Tests: 7 unit tests (all passing)
- Status: Production Ready
- Module:
src/mock.zig - Features:
- Mock function creation
- Call recording and tracking
- Call argument capture
- Call count assertions
- Return value mocking
- Spy functionality
- Mock reset
- API:
createMock()- Create mock instancecreateSpy()- Create spy instancetoHaveBeenCalled()- Called assertiontoHaveBeenCalledTimes()- Call count assertiontoHaveBeenCalledWith()- Argument assertiontoHaveBeenLastCalledWith()- Last call assertionmockReturnValue()- Set return value
- Status: Production Ready
- Module:
src/coverage.zig - Features:
- Line coverage tracking
- Branch coverage tracking
- Function coverage tracking
- HTML coverage reports
- Multiple coverage tool support (kcov, grindcov)
- Coverage summary output
- Tool availability detection
- Graceful fallback when tools unavailable
- CLI:
--coverage- Enable coverage--coverage-dir <dir>- Output directory--coverage-tool <tool>- Tool selection
- Status: Production Ready
- Module:
src/reporter.zig - Reporters:
- SpecReporter - Hierarchical colored output (default)
- DotReporter - Minimal dot output for CI
- JsonReporter - Machine-readable JSON
- TAPReporter - Test Anything Protocol
- JUnitReporter - JUnit XML format
- UIReporter - Web UI integration
- MultiReporter - Multiple reporters simultaneously
- Features:
- Colorized output (configurable)
- Execution timing
- Error details
- Summary statistics
- Progress indicators
- Status: Production Ready
- Module:
src/parallel.zig - Features:
- Configurable worker count
- Thread-based parallel execution
- Result aggregation across threads
- Thread-safe test execution
- Automatic CPU count detection
- Error handling in parallel mode
- Status: Production Ready
- Module:
src/snapshot.zig - Features:
- Snapshot creation and storage
- Snapshot comparison
- Update mode for snapshot refresh
- Multiple snapshot formats
- Snapshot file management
- String and struct snapshots
- Status: Production Ready
- Module:
src/watch.zig - Features:
- File system monitoring
- Automatic test re-run on changes
- Configurable watch patterns
- Debouncing support
- Clear screen option
- Initial run option
- Status: Production Ready
- Module:
src/memory_profiler.zig - Features:
- Memory allocation tracking
- Memory leak detection
- Peak memory usage reporting
- Per-test memory statistics
- Profiling allocator wrapper
- Memory usage visualization
- Status: Production Ready
- Module:
src/config.zig - Features:
- YAML configuration support
- JSON configuration support
- TOML configuration support
- Configuration validation
- Default configuration
- Environment-specific configs
- Status: Production Ready
- Module:
src/test_history.zig - Features:
- Test result persistence
- Historical result tracking
- Flaky test detection
- Performance trend analysis
- Test duration history
- Status: Production Ready
- Module:
src/ui_server.zig - Features:
- Web-based test UI
- Real-time test results
- Test filtering in UI
- Result visualization
- HTTP server integration
- Module:
src/cli.zig - Options:
--help/-h- Show help--version/-v- Show version--bail/-b- Stop on first failure--filter <pattern>- Filter tests by name--reporter <name>- Set reporter--verbose- Verbose output--quiet/-q- Minimal output--no-color- Disable colors--test-dir <dir>- Test directory--pattern <pattern>- File pattern--no-recursive- Disable recursion--coverage- Enable coverage--coverage-dir <dir>- Coverage directory--coverage-tool <tool>- Coverage tool--watch- Watch mode--parallel- Parallel execution--workers <n>- Worker count
- Total Modules: 23
- Total Lines of Code: ~8,000+
- Unit Tests: 60+ (all passing)
- Example Files: 4 (18 scenarios total)
- Documentation Files: 5
src/assertions.zig- 400+ linessrc/suite.zig- 500+ linessrc/test_runner.zig- 450+ linessrc/reporter.zig- 600+ linessrc/matchers.zig- 350+ linessrc/mock.zig- 300+ linessrc/cli.zig- 400+ linessrc/discovery.zig- 250+ linessrc/test_loader.zig- 200+ linessrc/coverage.zig- 450+ linessrc/parallel.zig- 300+ linessrc/ui_server.zig- 500+ linessrc/test_history.zig- 300+ linessrc/snapshot.zig- 350+ linessrc/watch.zig- 400+ linessrc/memory_profiler.zig- 400+ linessrc/config.zig- 350+ linessrc/async_support.zig- 400+ linessrc/async_test.zig- 570+ lines ⭐ NEWsrc/timeout.zig- 570+ lines ⭐ NEWsrc/lib.zig- 200 lines
examples/basic_test.zig- Basic usageexamples/advanced_test.zig- Advanced featuresexamples/async_tests.zig- 8 async scenarios ⭐ NEWexamples/timeout_examples.zig- 10 timeout scenarios ⭐ NEW
README.md- Main documentationASYNC_TEST_COMPLETE.md- Async test documentation ⭐ NEWTIMEOUT_COMPLETE.md- Timeout documentation ⭐ NEWFEATURES_SUMMARY.md- This document ⭐ NEWdocs/api.md- API reference
- ✅ Test registration functions (describe, it, test_)
- ✅ Async test functions (itAsync, itAsyncTimeout, etc.)
- ✅ Timeout functions (itTimeout, describeTimeout)
- ✅ Test filtering (skip, only)
- ✅ Assertions (expect, matchers)
- ✅ Hooks (beforeAll, afterAll, beforeEach, afterEach)
- ✅ Mocking (createMock, createSpy)
- ✅ Test execution (runTests, runTestsWithOptions)
- ✅ Reporters (all 5+ reporters)
- ✅ Coverage (runWithCoverage)
- ✅ Configuration (ConfigLoader)
- ✅ Snapshot (createSnapshot)
- ✅ Utilities (getRegistry, cleanupRegistry)
| Feature | Jest/Vitest | Zig Test Framework | Status |
|---|---|---|---|
| describe/it syntax | ✅ | ✅ | Complete |
| Assertions | ✅ | ✅ | Complete |
| Hooks | ✅ | ✅ | Complete |
| Mocking | ✅ | ✅ | Complete |
| Async tests | ✅ | ✅ | Complete |
| Timeout handling | ✅ | ✅ | Complete |
| Test filtering | ✅ | ✅ | Complete |
| Snapshot testing | ✅ | ✅ | Complete |
| Coverage | ✅ | ✅ | Complete |
| Watch mode | ✅ | ✅ | Complete |
| Reporters | ✅ | ✅ | Complete |
| Parallel execution | ✅ | ✅ | Complete |
| Configuration | ✅ | ✅ | Complete |
| Parameterized tests | ✅ | ⏳ | Planned |
| Property testing | ❌ | ⏳ | Planned |
| Feature | Bun Test | Zig Test Framework | Status |
|---|---|---|---|
| Fast execution | ✅ | ✅ | Complete |
| describe/it | ✅ | ✅ | Complete |
| Matchers | ✅ | ✅ | Complete |
| Mocking | ✅ | ✅ | Complete |
| Async tests | ✅ | ✅ | Complete |
| Snapshots | ✅ | ✅ | Complete |
| Coverage | ✅ | ✅ | Complete |
| Watch mode | ✅ | ✅ | Complete |
-
Use Test Discovery Mode:
zig-test --test-dir tests
-
Enable Coverage Regularly:
zig-test --test-dir tests --coverage
-
Use Async for I/O Tests:
try itAsync(allocator, "api call", testApiCall);
-
Set Appropriate Timeouts:
try itTimeout(allocator, "slow test", testFn, 10000);
-
Use Hooks for Setup/Teardown:
try beforeEach(alloc, setupFn); try afterEach(alloc, cleanupFn);
-
Always Clean Up:
defer cleanupRegistry();
- ✅ All features fully implemented
- ✅ All tests passing (60+ unit tests)
- ✅ No memory leaks
- ✅ Thread-safe where applicable
- ✅ Comprehensive documentation
- ✅ Example code provided
- ✅ API stable and consistent
- ✅ Error handling complete
- ✅ CI/CD ready
- Fast test execution
- Efficient memory usage
- Parallel execution support
- Optimized file discovery
- Minimal overhead
- v2.3.0 (2025-10-26): Added timeout handling
- v2.2.0 (2025-10-26): Added async test support
- v2.1.0 (Previous): Added snapshot, watch, memory profiling, config
- v2.0.0 (Previous): Added TAP/JUnit reporters, parallel execution
- v1.0.0 (Previous): Initial release with core features
- Parameterized tests (
it.each) - Property-based testing
- IDE integration (LSP support)
- Performance benchmarking
- Test impact analysis
- Smart test ordering
- Mutation testing
- Visual regression testing
- Native Zig async/await integration (when stable)
- Test retry logic for flaky tests
- Test dependencies and ordering
- Custom reporters API
- Plugin system
The Zig Test Framework is a complete, production-ready testing solution with all major features implemented:
- ✅ Core Testing: describe/it, assertions, hooks (100%)
- ✅ Advanced Features: async tests, timeouts, mocking (100%)
- ✅ Tooling: CLI, reporters, coverage, watch mode (100%)
- ✅ Developer Experience: Great DX with familiar API (100%)
Total Feature Completion: 100% (for planned v2.3.0 features)
The framework is ready for production use and provides a comprehensive testing solution comparable to industry-standard JavaScript testing frameworks!
Last Updated: 2025-10-26 Framework Version: 2.3.0 Status: Production Ready ✅