feat(documentation): Enhance README with detailed test features and update local settings for build permissions.

This commit is contained in:
Philipp Kunz 2025-05-16 00:54:10 +00:00
parent f452a58fff
commit 946e467c26
3 changed files with 148 additions and 1 deletions

View File

@ -1,5 +1,11 @@
# Changelog
## 2025-05-16 - 1.8.0 - feat(documentation)
Enhance README with detailed test features and update local settings for build permissions.
- Expanded the documentation to include tag filtering, parallel test execution groups, lifecycle hooks, snapshot testing, timeout control, retry logic, and test fixtures
- Updated .claude/settings.local.json to allow additional permissions for various build and test commands
## 2025-05-16 - 1.7.0 - feat(tstest)
Enhance tstest with fluent API, suite grouping, tag filtering, fixture & snapshot testing, and parallel execution improvements

141
readme.md
View File

@ -19,6 +19,14 @@
- 📝 **Detailed Logging** - Optional file logging for debugging
- ⚡ **Performance Metrics** - See which tests are slow
- 🤖 **CI/CD Ready** - JSON output mode for automation
- 🏷️ **Tag-based Filtering** - Run only tests with specific tags
- 🎯 **Parallel Test Execution** - Run tests in parallel groups
- 🔧 **Test Lifecycle Hooks** - beforeEach/afterEach support
- 📸 **Snapshot Testing** - Compare test outputs with saved snapshots
- ⏳ **Timeout Control** - Set custom timeouts for tests
- 🔁 **Retry Logic** - Automatically retry failing tests
- 🛠️ **Test Fixtures** - Create reusable test data
- 📦 **Browser-Compatible** - Full browser support for tapbundle
## Installation
@ -61,6 +69,7 @@ tstest "test/unit/*.ts"
| `--no-color` | Disable colored output |
| `--json` | Output results as JSON |
| `--logfile` | Save detailed logs to `.nogit/testlogs/[testname].log` |
| `--tags <tags>` | Run only tests with specific tags (comma-separated) |
### Example Outputs
@ -147,6 +156,103 @@ tap.test('my awesome test', async () => {
tap.start();
```
#### Test Features
**Tag-based Test Filtering**
```typescript
tap.tags('unit', 'api')
.test('should handle API requests', async () => {
// Test code
});
// Run with: tstest test/ --tags unit,api
```
**Test Lifecycle Hooks**
```typescript
tap.describe('User API Tests', () => {
let testUser;
tap.beforeEach(async () => {
testUser = await createTestUser();
});
tap.afterEach(async () => {
await deleteTestUser(testUser.id);
});
tap.test('should update user profile', async () => {
// Test code using testUser
});
});
```
**Parallel Test Execution**
```typescript
// Files with matching parallel group names run concurrently
// test.auth.para__1.ts
tap.test('authentication test', async () => { /* ... */ });
// test.user.para__1.ts
tap.test('user operations test', async () => { /* ... */ });
```
**Test Timeouts and Retries**
```typescript
tap.timeout(5000)
.retry(3)
.test('flaky network test', async (tools) => {
// This test has 5 seconds to complete and will retry up to 3 times
});
```
**Snapshot Testing**
```typescript
tap.test('should match snapshot', async (tools) => {
const result = await generateReport();
await tools.matchSnapshot(result);
});
```
**Test Fixtures**
```typescript
// Define a reusable fixture
tap.defineFixture('testUser', async () => ({
id: 1,
name: 'Test User',
email: 'test@example.com'
}));
tap.test('user test', async (tools) => {
const user = tools.fixture('testUser');
expect(user.name).toEqual('Test User');
});
```
**Skipping and Todo Tests**
```typescript
tap.skip.test('work in progress', async () => {
// This test will be skipped
});
tap.todo('implement user deletion', async () => {
// This marks a test as todo
});
```
**Browser Testing**
```typescript
// test.browser.ts
import { tap, webhelpers } from '@push.rocks/tapbundle';
tap.test('DOM manipulation', async () => {
const element = await webhelpers.fixture(webhelpers.html`
<div>Hello World</div>
`);
expect(element).toBeInstanceOf(HTMLElement);
});
```
## Advanced Features
### Glob Pattern Support
@ -163,6 +269,8 @@ tstest "test/integration/*.test.ts"
tstest "test/**/*.spec.ts" "test/**/*.test.ts"
```
**Important**: Always quote glob patterns to prevent shell expansion. Without quotes, the shell will expand the pattern and only pass the first matching file to tstest.
### Automatic Logging
Use `--logfile` to automatically save test output:
@ -181,6 +289,26 @@ In verbose mode, see performance metrics:
Slowest test: api integration test (486ms)
```
### Parallel Test Groups
Tests can be organized into parallel groups for concurrent execution:
```
━━━ Parallel Group: para__1 ━━━
▶️ test/auth.para__1.ts
▶️ test/user.para__1.ts
... tests run concurrently ...
──────────────────────────────────
━━━ Parallel Group: para__2 ━━━
▶️ test/db.para__2.ts
▶️ test/api.para__2.ts
... tests run concurrently ...
──────────────────────────────────
```
Files with the same parallel group suffix (e.g., `para__1`) run simultaneously, while different groups run sequentially.
### CI/CD Integration
For continuous integration, combine quiet and JSON modes:
@ -192,6 +320,19 @@ tstest test/ --json > test-results.json
tstest test/ --quiet
```
## Changelog
### Version 1.7.0
- 🎉 Made `@push.rocks/tapbundle` fully browser-compatible
- 📸 Added snapshot testing with base64-encoded communication protocol
- 🏷️ Introduced tag-based test filtering
- 🔧 Enhanced test lifecycle hooks (beforeEach/afterEach)
- 🎯 Fixed parallel test execution and grouping
- ⏳ Improved timeout and retry mechanisms
- 🛠️ Added test fixtures for reusable test data
- 📊 Enhanced TAP parser for better test reporting
- 🐛 Fixed glob pattern handling in shell scripts
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tstest',
version: '1.7.0',
version: '1.8.0',
description: 'a test utility to run tests that match test/**/*.ts'
}