@tspec/assert
v1.5.0
Published
Assertion library for TSpec testing framework
Maintainers
Readme
@tspec/assert
Assertion library for TSpec testing framework
ℹ️ Important Note
Provides the
expect()function and comprehensive assertion methods for testing.This package is designed to work as part of the TSpec ecosystem and Must be used with @tspec/core for test organization.
Installation
npm install --save-dev @tspec/core @tspec/assertFeatures
- 16+ assertion methods covering all common use cases
- Promise testing with
resolvesandrejects - Type-safe assertions with full TypeScript support
- Clear, descriptive error messages
Usage
import { expect } from '@tspec/assert';
// Basic assertions
expect(2 + 2).toBe(4);
expect('hello world').toContain('world');
expect([1, 2, 3]).toHaveLength(3);
// Async assertions
await expect(fetchData()).resolves.toEqual({ data: 'value' });
await expect(failingFunction()).rejects.toThrow('Error message');Complete Testing Example
import { describe, test } from '@tspec/core';
import { expect } from '@tspec/assert';
describe('assert Example', () => {
test('demonstrates assert functionality', () => {
// Comprehensive assertions
expect(42).toBe(42);
expect('hello').toContain('ell');
expect([1, 2, 3]).toHaveLength(3);
});
});Related Packages
TSpec is designed as a cohesive framework. Here are the related packages:
- @tspec/core - Core testing framework functionality for TSpec
- @tspec/mock - Mocking and spying utilities for TSpec testing framework
Documentation & Support
- 📖 Complete Documentation - Full usage guide and API reference
- 🚀 Getting Started Guide - Step-by-step setup
- 💡 Examples - Real-world usage examples
- 🐛 Issues - Report bugs or request features
Contributing
We welcome contributions! Please see our Contributing Guide for details on:
- Setting up the development environment
- Running tests and ensuring quality
- Submitting pull requests
License
MIT License - see the LICENSE file for details.
