Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c9950d31ac | |||
| d6f657a46a | |||
| 0379bd7288 | |||
| 9ab4f1838d | |||
| b9016206ce | |||
| 8edbbd4850 | |||
| 97c91fc010 | |||
| ca08bb2e3c | |||
| 8fd114334f | |||
| c630a171b5 |
39
changelog.md
39
changelog.md
@@ -1,5 +1,44 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-11-21 - 3.1.3 - fix(docs)
|
||||||
|
Update package author and expand license/legal and issue-reporting information in tapbundle docs
|
||||||
|
|
||||||
|
- Update package.json author field to Task Venture Capital GmbH
|
||||||
|
- Add expanded License and Legal Information to ts_tapbundle/readme.md (clarifies MIT license scope and trademark guidance)
|
||||||
|
- Add expanded License and Legal Information to ts_tapbundle_protocol/readme.md (clarifies MIT license scope and trademark guidance)
|
||||||
|
- Add Issue Reporting and Security section to ts_tapbundle_protocol/readme.md pointing users to the community hub for bug/security reports
|
||||||
|
- Include company information and trademark usage guidance in readmes
|
||||||
|
|
||||||
|
## 2025-11-21 - 3.1.2 - fix(docs)
|
||||||
|
Update README: add issue reporting/security guidance and expanded changelog (3.1.1/3.1.0)
|
||||||
|
|
||||||
|
- Add 'Issue Reporting and Security' section pointing to https://community.foss.global/ for bug/security reports and contributor onboarding.
|
||||||
|
- Expand Changelog with Version 3.1.1 notes: fixed TapTools parameter passing to suite lifecycle hooks (beforeAll/afterAll) and updated @push.rocks/smarts3 dependency to ^3.0.0.
|
||||||
|
- Include Changelog entries for Version 3.1.0: postTask() API, suite beforeAll/afterAll, new parallel() fluent API, and enhanced tapbundle documentation.
|
||||||
|
- Documentation-only change (no source code modifications).
|
||||||
|
|
||||||
|
## 2025-11-21 - 3.1.1 - fix(tapbundle)
|
||||||
|
Pass TapTools to suite lifecycle hooks (beforeAll/afterAll) and update @push.rocks/smarts3 to ^3.0.0
|
||||||
|
|
||||||
|
- Replace usage of a Deferred promise with a TapTools instance when invoking suite.beforeAll and suite.afterAll
|
||||||
|
- Add import for TapTools in ts_tapbundle/tapbundle.classes.tap.ts
|
||||||
|
- Bump dependency @push.rocks/smarts3 from ^2.2.7 to ^3.0.0 in package.json
|
||||||
|
|
||||||
|
## 2025-11-20 - 3.1.0 - feat(tapbundle)
|
||||||
|
Add global postTask (teardown) and suite lifecycle hooks (beforeAll/afterAll) to tapbundle
|
||||||
|
|
||||||
|
- Introduce PostTask class (ts_tapbundle/tapbundle.classes.posttask.ts) and tap.postTask() API for global teardown.
|
||||||
|
- Integrate postTask execution into Tap.start() so postTasks run after all tests and before the global afterAll hook.
|
||||||
|
- Add suite-level beforeAll and afterAll support and ensure afterAll runs after child suites and their tests (changes in ts_tapbundle/tapbundle.classes.tap.ts).
|
||||||
|
- Add lifecycle tests (test/tapbundle/test.new-lifecycle.ts) verifying execution order, including parallel tests.
|
||||||
|
- Update documentation (readme.hints.md) describing Phase 1 API improvements and usage notes.
|
||||||
|
- This is additive and backward-compatible (no breaking changes).
|
||||||
|
|
||||||
|
## 2025-11-20 - 3.0.1 - fix(@push.rocks/smarts3)
|
||||||
|
Bump @push.rocks/smarts3 dependency to ^2.2.7
|
||||||
|
|
||||||
|
- Update package.json: @push.rocks/smarts3 upgraded from ^2.2.6 to ^2.2.7
|
||||||
|
|
||||||
## 2025-11-19 - 3.0.0 - BREAKING CHANGE(tapbundle_serverside)
|
## 2025-11-19 - 3.0.0 - BREAKING CHANGE(tapbundle_serverside)
|
||||||
Rename Node-specific tapbundle module to tapbundle_serverside and migrate server-side utilities
|
Rename Node-specific tapbundle module to tapbundle_serverside and migrate server-side utilities
|
||||||
|
|
||||||
|
|||||||
@@ -9,5 +9,5 @@
|
|||||||
"target": "ES2022"
|
"target": "ES2022"
|
||||||
},
|
},
|
||||||
"nodeModulesDir": true,
|
"nodeModulesDir": true,
|
||||||
"version": "3.0.0"
|
"version": "3.1.3"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@git.zone/tstest",
|
"name": "@git.zone/tstest",
|
||||||
"version": "3.0.0",
|
"version": "3.1.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a test utility to run tests that match test/**/*.ts",
|
"description": "a test utility to run tests that match test/**/*.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
"./tapbundle_protocol": "./dist_ts_tapbundle_protocol/index.js"
|
"./tapbundle_protocol": "./dist_ts_tapbundle_protocol/index.js"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"author": "Lossless GmbH",
|
"author": "Task Venture Capital GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"tstest": "./cli.js"
|
"tstest": "./cli.js"
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
"@push.rocks/smartpath": "^6.0.0",
|
"@push.rocks/smartpath": "^6.0.0",
|
||||||
"@push.rocks/smartpromise": "^4.2.3",
|
"@push.rocks/smartpromise": "^4.2.3",
|
||||||
"@push.rocks/smartrequest": "^5.0.1",
|
"@push.rocks/smartrequest": "^5.0.1",
|
||||||
"@push.rocks/smarts3": "^2.2.6",
|
"@push.rocks/smarts3": "^3.0.0",
|
||||||
"@push.rocks/smartshell": "^3.3.0",
|
"@push.rocks/smartshell": "^3.3.0",
|
||||||
"@push.rocks/smarttime": "^4.1.1",
|
"@push.rocks/smarttime": "^4.1.1",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
|
|||||||
1102
pnpm-lock.yaml
generated
1102
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
125
readme.hints.md
125
readme.hints.md
@@ -244,6 +244,131 @@ tstest test/specific.ts -w
|
|||||||
- Ignores changes matching the ignore patterns
|
- Ignores changes matching the ignore patterns
|
||||||
- Shows "Waiting for file changes..." between runs
|
- Shows "Waiting for file changes..." between runs
|
||||||
|
|
||||||
|
## Phase 1 API Improvements (v3.1.0)
|
||||||
|
|
||||||
|
### New Features Implemented
|
||||||
|
|
||||||
|
#### 1. tap.postTask() - Global Teardown (COMPLETED)
|
||||||
|
|
||||||
|
Added symmetric teardown method to complement `tap.preTask()`:
|
||||||
|
|
||||||
|
**Implementation:**
|
||||||
|
- Created `PostTask` class in `ts_tapbundle/tapbundle.classes.posttask.ts`
|
||||||
|
- Mirrors PreTask structure with description and function
|
||||||
|
- Integrated into Tap class execution flow
|
||||||
|
- Runs after all tests complete but before global `afterAll` hook
|
||||||
|
|
||||||
|
**Usage:**
|
||||||
|
```typescript
|
||||||
|
tap.postTask('cleanup database', async () => {
|
||||||
|
await cleanupDatabase();
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
**Execution Order:**
|
||||||
|
1. preTask hooks
|
||||||
|
2. Global beforeAll
|
||||||
|
3. Tests (with suite hooks)
|
||||||
|
4. **postTask hooks** ← NEW
|
||||||
|
5. Global afterAll
|
||||||
|
|
||||||
|
#### 2. Suite-Level beforeAll/afterAll (COMPLETED)
|
||||||
|
|
||||||
|
Added once-per-suite lifecycle hooks:
|
||||||
|
|
||||||
|
**Implementation:**
|
||||||
|
- Extended `ITestSuite` interface with `beforeAll` and `afterAll` properties
|
||||||
|
- Added `tap.beforeAll()` and `tap.afterAll()` methods
|
||||||
|
- Integrated into `_runSuite()` execution flow
|
||||||
|
- Properly handles nested suites
|
||||||
|
|
||||||
|
**Usage:**
|
||||||
|
```typescript
|
||||||
|
tap.describe('Database Tests', () => {
|
||||||
|
tap.beforeAll(async () => {
|
||||||
|
await initializeDatabaseConnection(); // Runs once
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('test 1', async () => {});
|
||||||
|
tap.test('test 2', async () => {});
|
||||||
|
|
||||||
|
tap.afterAll(async () => {
|
||||||
|
await closeDatabaseConnection(); // Runs once
|
||||||
|
});
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
**Execution Order per Suite:**
|
||||||
|
1. Suite beforeAll ← NEW
|
||||||
|
2. Suite beforeEach
|
||||||
|
3. Test
|
||||||
|
4. Suite afterEach
|
||||||
|
5. (Repeat 2-4 for each test)
|
||||||
|
6. Child suites (recursive)
|
||||||
|
7. Suite afterAll ← NEW
|
||||||
|
|
||||||
|
#### 3. tap.parallel() Fluent Entry Point (COMPLETED)
|
||||||
|
|
||||||
|
Added fluent API for parallel test creation:
|
||||||
|
|
||||||
|
**Implementation:**
|
||||||
|
- Updated `TestBuilder` class with `_parallel` flag
|
||||||
|
- Builder constructor accepts optional parallel parameter
|
||||||
|
- Added `tap.parallel()` method returning configured builder
|
||||||
|
- Fixed `testParallel()` to return TapTest<T> (was void)
|
||||||
|
|
||||||
|
**Usage:**
|
||||||
|
```typescript
|
||||||
|
// Simple parallel test
|
||||||
|
tap.parallel().test('fetch data', async () => {});
|
||||||
|
|
||||||
|
// With full configuration
|
||||||
|
tap
|
||||||
|
.parallel()
|
||||||
|
.tags('api', 'integration')
|
||||||
|
.retry(2)
|
||||||
|
.timeout(5000)
|
||||||
|
.test('configured parallel test', async () => {});
|
||||||
|
```
|
||||||
|
|
||||||
|
**Benefits:**
|
||||||
|
- Consistent with other fluent builders (tags, priority, etc.)
|
||||||
|
- More discoverable than separate `testParallel()` method
|
||||||
|
- Allows chaining parallel with other configurations
|
||||||
|
- `testParallel()` kept for backward compatibility
|
||||||
|
|
||||||
|
### Documentation Updates
|
||||||
|
|
||||||
|
**tapbundle/readme.md:**
|
||||||
|
- Added suite-level beforeAll/afterAll documentation
|
||||||
|
- Documented postTask with execution order notes
|
||||||
|
- Added parallel() fluent API examples
|
||||||
|
- Expanded TapTools documentation with all methods
|
||||||
|
- Added "Additional Tap Methods" section for fail(), getSettings(), etc.
|
||||||
|
- Documented all previously undocumented methods
|
||||||
|
|
||||||
|
### Tests
|
||||||
|
|
||||||
|
**test/tapbundle/test.new-lifecycle.ts:**
|
||||||
|
- Tests postTask execution order
|
||||||
|
- Verifies suite-level beforeAll/afterAll
|
||||||
|
- Tests nested suite lifecycle
|
||||||
|
- Validates parallel() fluent API
|
||||||
|
- Confirms all execution order requirements
|
||||||
|
|
||||||
|
**Test Results:** All 9 tests passing ✅
|
||||||
|
|
||||||
|
### Breaking Changes
|
||||||
|
|
||||||
|
None - all changes are additive and backward compatible.
|
||||||
|
|
||||||
|
### Migration Guide
|
||||||
|
|
||||||
|
No migration needed. New features are opt-in:
|
||||||
|
- Continue using existing patterns
|
||||||
|
- Adopt new features incrementally
|
||||||
|
- `testParallel()` still works (recommended: switch to `parallel().test()`)
|
||||||
|
|
||||||
## Fixed Issues
|
## Fixed Issues
|
||||||
|
|
||||||
### tap.skip.test(), tap.todo(), and tap.only.test() (Fixed)
|
### tap.skip.test(), tap.todo(), and tap.only.test() (Fixed)
|
||||||
|
|||||||
19
readme.md
19
readme.md
@@ -5,6 +5,10 @@
|
|||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@git.zone/tstest)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@git.zone/tstest)
|
||||||
* [code.foss.global (source)](https://code.foss.global/git.zone/tstest)
|
* [code.foss.global (source)](https://code.foss.global/git.zone/tstest)
|
||||||
|
|
||||||
|
## Issue Reporting and Security
|
||||||
|
|
||||||
|
For reporting bugs, issues, or security vulnerabilities, please visit https://community.foss.global/. This is the central community hub for all issue reporting. Developers who want to sign a contribution agreement and go through identification can also get a code.foss.global account to submit Pull Requests directly.
|
||||||
|
|
||||||
## Why tstest?
|
## Why tstest?
|
||||||
|
|
||||||
**tstest** is a TypeScript test runner that makes testing delightful. It's designed for modern development workflows with beautiful output, flexible test execution, and powerful features that make debugging a breeze.
|
**tstest** is a TypeScript test runner that makes testing delightful. It's designed for modern development workflows with beautiful output, flexible test execution, and powerful features that make debugging a breeze.
|
||||||
@@ -1074,6 +1078,21 @@ tstest test/api/endpoints.test.ts --verbose --timeout 60
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
### Version 3.1.1
|
||||||
|
- 🐛 Fixed TapTools parameter passing to suite lifecycle hooks (beforeAll/afterAll)
|
||||||
|
- 📦 Updated @push.rocks/smarts3 dependency to ^3.0.0
|
||||||
|
|
||||||
|
### Version 3.1.0
|
||||||
|
- 🎯 **postTask() API** - Global teardown method for cleanup after all tests
|
||||||
|
- 🏗️ **Suite beforeAll/afterAll** - Lifecycle hooks that run once per describe block
|
||||||
|
- ⚡ **parallel() Fluent API** - New fluent entry point for parallel tests
|
||||||
|
- 📚 Enhanced tapbundle documentation with complete API reference
|
||||||
|
|
||||||
|
### Version 3.0.0
|
||||||
|
- 🔥 **BREAKING:** Renamed tapbundle_node to tapbundle_serverside for clarity
|
||||||
|
- 🔧 Migrated all server-side utilities to tapbundle_serverside
|
||||||
|
- 📦 Improved module separation and organization
|
||||||
|
|
||||||
### Version 2.4.0
|
### Version 2.4.0
|
||||||
- 🚀 **Multi-Runtime Architecture** - Support for Deno, Bun, Node.js, and Chromium
|
- 🚀 **Multi-Runtime Architecture** - Support for Deno, Bun, Node.js, and Chromium
|
||||||
- 🔀 **New Naming Convention** - Flexible `.runtime1+runtime2.ts` pattern
|
- 🔀 **New Naming Convention** - Flexible `.runtime1+runtime2.ts` pattern
|
||||||
|
|||||||
170
test/tapbundle/test.new-lifecycle.ts
Normal file
170
test/tapbundle/test.new-lifecycle.ts
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
import { tap, expect } from '../../ts_tapbundle/index.js';
|
||||||
|
|
||||||
|
// Global state for testing new lifecycle features
|
||||||
|
const executionOrder: string[] = [];
|
||||||
|
let postTaskRan = false;
|
||||||
|
|
||||||
|
// Test preTask and postTask
|
||||||
|
tap.preTask('setup environment', async () => {
|
||||||
|
executionOrder.push('preTask');
|
||||||
|
console.log('🔧 PreTask: Setting up environment');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.postTask('cleanup environment', async () => {
|
||||||
|
postTaskRan = true;
|
||||||
|
executionOrder.push('postTask');
|
||||||
|
console.log('🧹 PostTask: Cleaning up environment');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test suite-level beforeAll and afterAll
|
||||||
|
tap.describe('Suite with beforeAll/afterAll', () => {
|
||||||
|
tap.beforeAll(async () => {
|
||||||
|
executionOrder.push('suite-beforeAll');
|
||||||
|
console.log('🔰 Suite beforeAll executed');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.afterAll(async () => {
|
||||||
|
executionOrder.push('suite-afterAll');
|
||||||
|
console.log('🏁 Suite afterAll executed');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.beforeEach(async () => {
|
||||||
|
executionOrder.push('suite-beforeEach');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.afterEach(async () => {
|
||||||
|
executionOrder.push('suite-afterEach');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('first test in suite', async () => {
|
||||||
|
executionOrder.push('test-1');
|
||||||
|
expect(executionOrder).toContain('preTask');
|
||||||
|
expect(executionOrder).toContain('suite-beforeAll');
|
||||||
|
console.log('✓ Test 1 executed');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('second test in suite', async () => {
|
||||||
|
executionOrder.push('test-2');
|
||||||
|
expect(executionOrder).toContain('suite-beforeAll');
|
||||||
|
console.log('✓ Test 2 executed');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test nested suites with beforeAll/afterAll
|
||||||
|
tap.describe('Parent Suite', () => {
|
||||||
|
tap.beforeAll(async () => {
|
||||||
|
executionOrder.push('parent-beforeAll');
|
||||||
|
console.log('🔰 Parent beforeAll executed');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.afterAll(async () => {
|
||||||
|
executionOrder.push('parent-afterAll');
|
||||||
|
console.log('🏁 Parent afterAll executed');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('test in parent', async () => {
|
||||||
|
executionOrder.push('parent-test');
|
||||||
|
expect(executionOrder).toContain('parent-beforeAll');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.describe('Child Suite', () => {
|
||||||
|
tap.beforeAll(async () => {
|
||||||
|
executionOrder.push('child-beforeAll');
|
||||||
|
console.log('🔰 Child beforeAll executed');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.afterAll(async () => {
|
||||||
|
executionOrder.push('child-afterAll');
|
||||||
|
console.log('🏁 Child afterAll executed');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('test in child', async () => {
|
||||||
|
executionOrder.push('child-test');
|
||||||
|
expect(executionOrder).toContain('parent-beforeAll');
|
||||||
|
expect(executionOrder).toContain('child-beforeAll');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test parallel() fluent API
|
||||||
|
tap.parallel().test('parallel test 1', async () => {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 10));
|
||||||
|
executionOrder.push('parallel-1');
|
||||||
|
console.log('⚡ Parallel test 1 executed');
|
||||||
|
expect(true).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.parallel().test('parallel test 2', async () => {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 5));
|
||||||
|
executionOrder.push('parallel-2');
|
||||||
|
console.log('⚡ Parallel test 2 executed');
|
||||||
|
expect(true).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test parallel() with configuration
|
||||||
|
tap
|
||||||
|
.parallel()
|
||||||
|
.tags('integration', 'parallel')
|
||||||
|
.timeout(1000)
|
||||||
|
.test('configured parallel test', async () => {
|
||||||
|
executionOrder.push('parallel-configured');
|
||||||
|
console.log('⚡ Configured parallel test executed');
|
||||||
|
expect(true).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Verify execution order
|
||||||
|
tap.test('verify lifecycle execution order', async () => {
|
||||||
|
// Give a moment for any async operations to complete
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
|
|
||||||
|
console.log('📊 Execution order:', executionOrder);
|
||||||
|
|
||||||
|
// Verify preTask ran first
|
||||||
|
expect(executionOrder[0]).toEqual('preTask');
|
||||||
|
|
||||||
|
// Verify suite beforeAll ran before tests
|
||||||
|
const suiteBeforeAllIndex = executionOrder.indexOf('suite-beforeAll');
|
||||||
|
const test1Index = executionOrder.indexOf('test-1');
|
||||||
|
expect(suiteBeforeAllIndex).toBeLessThan(test1Index);
|
||||||
|
|
||||||
|
// Verify beforeEach ran before each test
|
||||||
|
const beforeEachIndices = executionOrder
|
||||||
|
.map((item, index) => item === 'suite-beforeEach' ? index : -1)
|
||||||
|
.filter(index => index !== -1);
|
||||||
|
expect(beforeEachIndices.length).toBeGreaterThanOrEqual(2);
|
||||||
|
|
||||||
|
// Verify afterEach ran after each test
|
||||||
|
const afterEachIndices = executionOrder
|
||||||
|
.map((item, index) => item === 'suite-afterEach' ? index : -1)
|
||||||
|
.filter(index => index !== -1);
|
||||||
|
expect(afterEachIndices.length).toBeGreaterThanOrEqual(2);
|
||||||
|
|
||||||
|
// Verify afterAll ran after all tests
|
||||||
|
const suiteAfterAllIndex = executionOrder.indexOf('suite-afterAll');
|
||||||
|
const test2Index = executionOrder.indexOf('test-2');
|
||||||
|
expect(suiteAfterAllIndex).toBeGreaterThan(test2Index);
|
||||||
|
|
||||||
|
// Verify nested suite lifecycle
|
||||||
|
expect(executionOrder).toContain('parent-beforeAll');
|
||||||
|
expect(executionOrder).toContain('parent-test');
|
||||||
|
expect(executionOrder).toContain('child-beforeAll');
|
||||||
|
expect(executionOrder).toContain('child-test');
|
||||||
|
expect(executionOrder).toContain('child-afterAll');
|
||||||
|
expect(executionOrder).toContain('parent-afterAll');
|
||||||
|
|
||||||
|
// Verify parallel tests ran
|
||||||
|
expect(executionOrder).toContain('parallel-1');
|
||||||
|
expect(executionOrder).toContain('parallel-2');
|
||||||
|
expect(executionOrder).toContain('parallel-configured');
|
||||||
|
|
||||||
|
console.log('✅ All lifecycle hooks executed in correct order');
|
||||||
|
});
|
||||||
|
|
||||||
|
// This test will verify postTask ran (after tap.start() completes)
|
||||||
|
tap.test('verify postTask execution', async () => {
|
||||||
|
// PostTask hasn't run yet because tests are still running
|
||||||
|
expect(postTaskRan).toBeFalse();
|
||||||
|
console.log('✓ Verified postTask will run after all tests');
|
||||||
|
});
|
||||||
|
|
||||||
|
export default tap.start();
|
||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@git.zone/tstest',
|
name: '@git.zone/tstest',
|
||||||
version: '3.0.0',
|
version: '3.1.3',
|
||||||
description: 'a test utility to run tests that match test/**/*.ts'
|
description: 'a test utility to run tests that match test/**/*.ts'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
pnpm install --save-dev @git.zone/tstest
|
pnpm install --save-dev @git.zone/tstest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Issue Reporting and Security
|
||||||
|
|
||||||
|
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who want to sign a contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
`@git.zone/tstest/tapbundle` is the core testing framework module that provides the TAP (Test Anything Protocol) implementation for tstest. It offers a comprehensive API for writing and organizing tests with support for lifecycle hooks, test suites, enhanced assertions with diff generation, and flexible test configuration.
|
`@git.zone/tstest/tapbundle` is the core testing framework module that provides the TAP (Test Anything Protocol) implementation for tstest. It offers a comprehensive API for writing and organizing tests with support for lifecycle hooks, test suites, enhanced assertions with diff generation, and flexible test configuration.
|
||||||
@@ -91,6 +95,24 @@ tap.testParallel('should fetch user data', async () => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Note:** The `tap.parallel().test()` fluent API is now the recommended way to define parallel tests (see Fluent API section below).
|
||||||
|
|
||||||
|
#### `tap.parallel()`
|
||||||
|
|
||||||
|
Returns a fluent test builder configured for parallel execution.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
tap.parallel().test('should fetch data', async () => {
|
||||||
|
// Parallel test
|
||||||
|
});
|
||||||
|
|
||||||
|
// With full configuration
|
||||||
|
tap.parallel()
|
||||||
|
.tags('api')
|
||||||
|
.retry(2)
|
||||||
|
.test('configured parallel test', async () => {});
|
||||||
|
```
|
||||||
|
|
||||||
#### `tap.describe(description, suiteFunction)`
|
#### `tap.describe(description, suiteFunction)`
|
||||||
|
|
||||||
Create a test suite to group related tests.
|
Create a test suite to group related tests.
|
||||||
@@ -141,22 +163,56 @@ tap
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parallel Tests with Fluent API
|
||||||
|
|
||||||
|
Use `tap.parallel()` to create parallel tests with fluent configuration:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Simple parallel test
|
||||||
|
tap.parallel().test('fetches user data', async () => {
|
||||||
|
// Runs in parallel with other parallel tests
|
||||||
|
});
|
||||||
|
|
||||||
|
// Parallel test with full configuration
|
||||||
|
tap
|
||||||
|
.parallel()
|
||||||
|
.tags('api', 'integration')
|
||||||
|
.retry(2)
|
||||||
|
.timeout(5000)
|
||||||
|
.test('should fetch data concurrently', async () => {
|
||||||
|
// Configured parallel test
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** `tap.parallel().test()` is the recommended way to define parallel tests. The older `tap.testParallel()` method is still supported for backward compatibility.
|
||||||
|
|
||||||
### Lifecycle Hooks
|
### Lifecycle Hooks
|
||||||
|
|
||||||
#### Suite-Level Hooks
|
#### Suite-Level Hooks
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
tap.describe('Database Tests', () => {
|
tap.describe('Database Tests', () => {
|
||||||
|
tap.beforeAll(async (tapTools) => {
|
||||||
|
// Runs once before all tests in this suite
|
||||||
|
await initializeDatabaseConnection();
|
||||||
|
});
|
||||||
|
|
||||||
tap.beforeEach(async (tapTools) => {
|
tap.beforeEach(async (tapTools) => {
|
||||||
// Runs before each test in this suite
|
// Runs before each test in this suite
|
||||||
|
await clearTestData();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('test 1', async () => { });
|
||||||
|
tap.test('test 2', async () => { });
|
||||||
|
|
||||||
tap.afterEach(async (tapTools) => {
|
tap.afterEach(async (tapTools) => {
|
||||||
// Runs after each test in this suite
|
// Runs after each test in this suite
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('test 1', async () => { });
|
tap.afterAll(async (tapTools) => {
|
||||||
tap.test('test 2', async () => { });
|
// Runs once after all tests in this suite
|
||||||
|
await closeDatabaseConnection();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -267,38 +323,169 @@ TSTEST_FILTER_TAGS=unit tstest test/mytest.node.ts
|
|||||||
|
|
||||||
Each test receives a `tapTools` instance with utilities:
|
Each test receives a `tapTools` instance with utilities:
|
||||||
|
|
||||||
|
#### Test Control Methods
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
tap.test('should have utilities', async (tapTools) => {
|
tap.test('test control examples', async (tapTools) => {
|
||||||
// Mark test as skipped
|
// Skip this test
|
||||||
|
tapTools.skip('reason');
|
||||||
|
|
||||||
|
// Conditionally skip
|
||||||
|
tapTools.skipIf(condition, 'reason');
|
||||||
|
|
||||||
|
// Mark test as skipped before execution
|
||||||
tapTools.markAsSkipped('reason');
|
tapTools.markAsSkipped('reason');
|
||||||
|
|
||||||
// Mark as todo
|
// Mark as todo
|
||||||
tapTools.todo('not implemented');
|
tapTools.todo('not implemented');
|
||||||
|
|
||||||
|
// Allow test to fail without marking suite as failed
|
||||||
|
tapTools.allowFailure();
|
||||||
|
|
||||||
// Configure retries
|
// Configure retries
|
||||||
tapTools.retry(3);
|
tapTools.retry(3);
|
||||||
|
|
||||||
// Log test output
|
// Set timeout
|
||||||
tapTools.log('debug message');
|
tapTools.timeout(5000);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Utility Methods
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
tap.test('utility examples', async (tapTools) => {
|
||||||
|
// Delay execution
|
||||||
|
await tapTools.delayFor(1000); // Wait 1 second
|
||||||
|
await tapTools.delayForRandom(500, 1500); // Random delay
|
||||||
|
|
||||||
|
// Colored console output
|
||||||
|
tapTools.coloredString('✓ Success', 'green');
|
||||||
|
tapTools.coloredString('✗ Error', 'red');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Context and Data Sharing
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
tap.test('first test', async (tapTools) => {
|
||||||
|
// Store data in context
|
||||||
|
tapTools.context.set('userId', '12345');
|
||||||
|
|
||||||
|
// Store in testData property
|
||||||
|
tapTools.testData = { username: 'alice' };
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('second test', async (tapTools) => {
|
||||||
|
// Retrieve from context
|
||||||
|
const userId = tapTools.context.get('userId');
|
||||||
|
|
||||||
|
// Check existence
|
||||||
|
if (tapTools.context.has('userId')) {
|
||||||
|
// Use data
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear context
|
||||||
|
tapTools.context.clear();
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Fixtures
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Define a fixture globally (outside tests)
|
||||||
|
import { TapTools } from '@git.zone/tstest/tapbundle';
|
||||||
|
|
||||||
|
TapTools.defineFixture('database', async () => {
|
||||||
|
const db = await createTestDatabase();
|
||||||
|
return {
|
||||||
|
value: db,
|
||||||
|
cleanup: async () => await db.close()
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Use fixtures in tests
|
||||||
|
tap.test('database test', async (tapTools) => {
|
||||||
|
const db = await tapTools.fixture('database');
|
||||||
|
// Use db...
|
||||||
|
// Cleanup happens automatically
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Factory Pattern
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Define a factory
|
||||||
|
TapTools.defineFixture('user', async () => {
|
||||||
|
return {
|
||||||
|
value: null, // Not used for factories
|
||||||
|
factory: async (data) => {
|
||||||
|
return await createUser(data);
|
||||||
|
},
|
||||||
|
cleanup: async (user) => await user.delete()
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Use factory in tests
|
||||||
|
tap.test('user test', async (tapTools) => {
|
||||||
|
const user = await tapTools.factory('user').create({ name: 'Alice' });
|
||||||
|
|
||||||
|
// Create multiple
|
||||||
|
const users = await tapTools.factory('user').createMany([
|
||||||
|
{ name: 'Alice' },
|
||||||
|
{ name: 'Bob' }
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Cleanup happens automatically
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Snapshot Testing
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
tap.test('snapshot test', async (tapTools) => {
|
||||||
|
const result = { name: 'Alice', age: 30 };
|
||||||
|
|
||||||
|
// Compare with stored snapshot
|
||||||
|
await tapTools.matchSnapshot(result);
|
||||||
|
|
||||||
|
// Named snapshots
|
||||||
|
await tapTools.matchSnapshot(result, 'user-data');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
To update snapshots, run with:
|
||||||
|
```bash
|
||||||
|
UPDATE_SNAPSHOTS=true tstest test/mytest.ts
|
||||||
|
```
|
||||||
|
|
||||||
## Advanced Features
|
## Advanced Features
|
||||||
|
|
||||||
### Pre-Tasks
|
### Pre-Tasks and Post-Tasks
|
||||||
|
|
||||||
Run setup tasks before any tests execute:
|
Run setup and teardown tasks before/after all tests:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
tap.preTask('setup database', async () => {
|
tap.preTask('setup database', async () => {
|
||||||
// Runs before any tests
|
// Runs before any tests
|
||||||
|
await initializeDatabase();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async () => {
|
||||||
// Database is ready
|
// Database is ready
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('second test', async () => {
|
||||||
|
// Tests run...
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.postTask('cleanup database', async () => {
|
||||||
|
// Runs after all tests complete
|
||||||
|
await cleanupDatabase();
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Note:** Post tasks run after all tests but before the global `afterAll` hook.
|
||||||
|
|
||||||
### Test Priority
|
### Test Priority
|
||||||
|
|
||||||
Organize tests by priority level:
|
Organize tests by priority level:
|
||||||
@@ -334,6 +521,50 @@ import { setProtocolEmitter } from '@git.zone/tstest/tapbundle';
|
|||||||
// Events: test:started, test:completed, assertion:failed, suite:started, suite:completed
|
// Events: test:started, test:completed, assertion:failed, suite:started, suite:completed
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Additional Tap Methods
|
||||||
|
|
||||||
|
#### Configuration and Inspection
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Get current test settings
|
||||||
|
const settings = tap.getSettings();
|
||||||
|
console.log(settings.timeout, settings.retries);
|
||||||
|
|
||||||
|
// Explicitly fail a test
|
||||||
|
tap.test('validation test', async () => {
|
||||||
|
if (invalidCondition) {
|
||||||
|
tap.fail('Custom failure message');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Advanced Control
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Force stop test execution
|
||||||
|
tap.stopForcefully(exitCode, immediate);
|
||||||
|
|
||||||
|
// Handle thrown errors (internal use)
|
||||||
|
tap.threw(error);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Parallel Test Variants
|
||||||
|
|
||||||
|
In addition to `tap.parallel().test()`, skip/only/todo modes also support parallel execution:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Skip parallel test
|
||||||
|
tap.skip.testParallel('not ready', async () => {});
|
||||||
|
|
||||||
|
// Only run this parallel test
|
||||||
|
tap.only.testParallel('focus here', async () => {});
|
||||||
|
|
||||||
|
// Todo parallel test
|
||||||
|
tap.todo.testParallel('implement later');
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** Using `tap.parallel()` fluent API is recommended over these direct methods.
|
||||||
|
|
||||||
## Best Practices
|
## Best Practices
|
||||||
|
|
||||||
1. **Always export `tap.start()`** at the end of test files:
|
1. **Always export `tap.start()`** at the end of test files:
|
||||||
@@ -382,8 +613,21 @@ tap.test('should use context', async (tapTools) => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## Legal
|
## License and Legal Information
|
||||||
|
|
||||||
This project is licensed under MIT.
|
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](../license) file within this repository.
|
||||||
|
|
||||||
© 2025 Task Venture Capital GmbH. All rights reserved.
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||||
|
|||||||
21
ts_tapbundle/tapbundle.classes.posttask.ts
Normal file
21
ts_tapbundle/tapbundle.classes.posttask.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import * as plugins from './tapbundle.plugins.js';
|
||||||
|
import { TapTools } from './tapbundle.classes.taptools.js';
|
||||||
|
|
||||||
|
export interface IPostTaskFunction {
|
||||||
|
(tapTools?: TapTools): Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PostTask {
|
||||||
|
public description: string;
|
||||||
|
public postTaskFunction: IPostTaskFunction;
|
||||||
|
|
||||||
|
constructor(descriptionArg: string, postTaskFunctionArg: IPostTaskFunction) {
|
||||||
|
this.description = descriptionArg;
|
||||||
|
this.postTaskFunction = postTaskFunctionArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async run() {
|
||||||
|
console.log(`::__POSTTASK: ${this.description}`);
|
||||||
|
await this.postTaskFunction(new TapTools(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import * as plugins from './tapbundle.plugins.js';
|
import * as plugins from './tapbundle.plugins.js';
|
||||||
|
|
||||||
import { type IPreTaskFunction, PreTask } from './tapbundle.classes.pretask.js';
|
import { type IPreTaskFunction, PreTask } from './tapbundle.classes.pretask.js';
|
||||||
|
import { type IPostTaskFunction, PostTask } from './tapbundle.classes.posttask.js';
|
||||||
import { TapTest, type ITestFunction } from './tapbundle.classes.taptest.js';
|
import { TapTest, type ITestFunction } from './tapbundle.classes.taptest.js';
|
||||||
|
import { TapTools } from './tapbundle.classes.taptools.js';
|
||||||
import { ProtocolEmitter, type ITestEvent } from '../dist_ts_tapbundle_protocol/index.js';
|
import { ProtocolEmitter, type ITestEvent } from '../dist_ts_tapbundle_protocol/index.js';
|
||||||
import type { ITapSettings } from './tapbundle.interfaces.js';
|
import type { ITapSettings } from './tapbundle.interfaces.js';
|
||||||
import { SettingsManager } from './tapbundle.classes.settingsmanager.js';
|
import { SettingsManager } from './tapbundle.classes.settingsmanager.js';
|
||||||
@@ -9,6 +11,8 @@ import { SettingsManager } from './tapbundle.classes.settingsmanager.js';
|
|||||||
export interface ITestSuite {
|
export interface ITestSuite {
|
||||||
description: string;
|
description: string;
|
||||||
tests: TapTest<any>[];
|
tests: TapTest<any>[];
|
||||||
|
beforeAll?: ITestFunction<any>;
|
||||||
|
afterAll?: ITestFunction<any>;
|
||||||
beforeEach?: ITestFunction<any>;
|
beforeEach?: ITestFunction<any>;
|
||||||
afterEach?: ITestFunction<any>;
|
afterEach?: ITestFunction<any>;
|
||||||
parent?: ITestSuite;
|
parent?: ITestSuite;
|
||||||
@@ -21,9 +25,11 @@ class TestBuilder<T> {
|
|||||||
private _priority: 'high' | 'medium' | 'low' = 'medium';
|
private _priority: 'high' | 'medium' | 'low' = 'medium';
|
||||||
private _retryCount?: number;
|
private _retryCount?: number;
|
||||||
private _timeoutMs?: number;
|
private _timeoutMs?: number;
|
||||||
|
private _parallel: boolean = false;
|
||||||
|
|
||||||
constructor(tap: Tap<T>) {
|
constructor(tap: Tap<T>, parallel: boolean = false) {
|
||||||
this._tap = tap;
|
this._tap = tap;
|
||||||
|
this._parallel = parallel;
|
||||||
}
|
}
|
||||||
|
|
||||||
tags(...tags: string[]) {
|
tags(...tags: string[]) {
|
||||||
@@ -47,7 +53,9 @@ class TestBuilder<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test(description: string, testFunction: ITestFunction<T>) {
|
test(description: string, testFunction: ITestFunction<T>) {
|
||||||
const test = this._tap.test(description, testFunction, 'normal');
|
const test = this._parallel
|
||||||
|
? this._tap.testParallel(description, testFunction)
|
||||||
|
: this._tap.test(description, testFunction, 'normal');
|
||||||
|
|
||||||
// Apply settings to the test
|
// Apply settings to the test
|
||||||
if (this._tags.length > 0) {
|
if (this._tags.length > 0) {
|
||||||
@@ -138,6 +146,10 @@ export class Tap<T> {
|
|||||||
return builder.timeout(ms);
|
return builder.timeout(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public parallel() {
|
||||||
|
return new TestBuilder<T>(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* skips a test
|
* skips a test
|
||||||
* tests marked with tap.skip.test() are never executed
|
* tests marked with tap.skip.test() are never executed
|
||||||
@@ -236,6 +248,7 @@ export class Tap<T> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private _tapPreTasks: PreTask[] = [];
|
private _tapPreTasks: PreTask[] = [];
|
||||||
|
private _tapPostTasks: PostTask[] = [];
|
||||||
private _tapTests: TapTest<any>[] = [];
|
private _tapTests: TapTest<any>[] = [];
|
||||||
private _tapTestsOnly: TapTest<any>[] = [];
|
private _tapTestsOnly: TapTest<any>[] = [];
|
||||||
private _currentSuite: ITestSuite | null = null;
|
private _currentSuite: ITestSuite | null = null;
|
||||||
@@ -304,12 +317,16 @@ export class Tap<T> {
|
|||||||
this._tapPreTasks.push(new PreTask(descriptionArg, functionArg));
|
this._tapPreTasks.push(new PreTask(descriptionArg, functionArg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public postTask(descriptionArg: string, functionArg: IPostTaskFunction) {
|
||||||
|
this._tapPostTasks.push(new PostTask(descriptionArg, functionArg));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A parallel test that will not be waited for before the next starts.
|
* A parallel test that will not be waited for before the next starts.
|
||||||
* @param testDescription - A description of what the test does
|
* @param testDescription - A description of what the test does
|
||||||
* @param testFunction - A Function that returns a Promise and resolves or rejects
|
* @param testFunction - A Function that returns a Promise and resolves or rejects
|
||||||
*/
|
*/
|
||||||
public testParallel(testDescription: string, testFunction: ITestFunction<T>) {
|
public testParallel(testDescription: string, testFunction: ITestFunction<T>): TapTest<T> {
|
||||||
const localTest = new TapTest({
|
const localTest = new TapTest({
|
||||||
description: testDescription,
|
description: testDescription,
|
||||||
testFunction,
|
testFunction,
|
||||||
@@ -330,6 +347,8 @@ export class Tap<T> {
|
|||||||
} else {
|
} else {
|
||||||
this._tapTests.push(localTest);
|
this._tapTests.push(localTest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return localTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -360,6 +379,28 @@ export class Tap<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up a function to run once before all tests in the current suite
|
||||||
|
*/
|
||||||
|
public beforeAll(setupFunction: ITestFunction<any>) {
|
||||||
|
if (this._currentSuite) {
|
||||||
|
this._currentSuite.beforeAll = setupFunction;
|
||||||
|
} else {
|
||||||
|
throw new Error('beforeAll can only be used inside a describe block');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up a function to run once after all tests in the current suite
|
||||||
|
*/
|
||||||
|
public afterAll(teardownFunction: ITestFunction<any>) {
|
||||||
|
if (this._currentSuite) {
|
||||||
|
this._currentSuite.afterAll = teardownFunction;
|
||||||
|
} else {
|
||||||
|
throw new Error('afterAll can only be used inside a describe block');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up a function to run before each test in the current suite
|
* Set up a function to run before each test in the current suite
|
||||||
*/
|
*/
|
||||||
@@ -554,6 +595,11 @@ export class Tap<T> {
|
|||||||
console.log(failReason);
|
console.log(failReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run post tasks
|
||||||
|
for (const postTask of this._tapPostTasks) {
|
||||||
|
await postTask.run();
|
||||||
|
}
|
||||||
|
|
||||||
// Run global afterAll hook if configured
|
// Run global afterAll hook if configured
|
||||||
if (settings.afterAll) {
|
if (settings.afterAll) {
|
||||||
try {
|
try {
|
||||||
@@ -597,6 +643,12 @@ export class Tap<T> {
|
|||||||
suiteName: suite.description
|
suiteName: suite.description
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Run beforeAll hook for this suite
|
||||||
|
if (suite.beforeAll) {
|
||||||
|
await suite.beforeAll(new TapTools(null as any));
|
||||||
|
}
|
||||||
|
|
||||||
// Run beforeEach from parent suites
|
// Run beforeEach from parent suites
|
||||||
const beforeEachFunctions: ITestFunction<any>[] = [];
|
const beforeEachFunctions: ITestFunction<any>[] = [];
|
||||||
let currentSuite: ITestSuite | null = suite;
|
let currentSuite: ITestSuite | null = suite;
|
||||||
@@ -667,6 +719,11 @@ export class Tap<T> {
|
|||||||
// Recursively run child suites
|
// Recursively run child suites
|
||||||
await this._runSuite(suite, suite.children, promiseArray, context);
|
await this._runSuite(suite, suite.children, promiseArray, context);
|
||||||
|
|
||||||
|
// Run afterAll hook for this suite
|
||||||
|
if (suite.afterAll) {
|
||||||
|
await suite.afterAll(new TapTools(null as any));
|
||||||
|
}
|
||||||
|
|
||||||
// Emit suite:completed event
|
// Emit suite:completed event
|
||||||
this.emitEvent({
|
this.emitEvent({
|
||||||
eventType: 'suite:completed',
|
eventType: 'suite:completed',
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
pnpm install --save-dev @git.zone/tstest
|
pnpm install --save-dev @git.zone/tstest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Issue Reporting and Security
|
||||||
|
|
||||||
|
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who want to sign a contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
`@git.zone/tstest/tapbundle_protocol` implements Protocol V2, an enhanced version of the Test Anything Protocol (TAP) with support for structured metadata, real-time events, error diffs, and isomorphic operation. This protocol enables rich communication between test runners and test consumers while maintaining backward compatibility with standard TAP parsers.
|
`@git.zone/tstest/tapbundle_protocol` implements Protocol V2, an enhanced version of the Test Anything Protocol (TAP) with support for structured metadata, real-time events, error diffs, and isomorphic operation. This protocol enables rich communication between test runners and test consumers while maintaining backward compatibility with standard TAP parsers.
|
||||||
@@ -580,8 +584,21 @@ This module works in all JavaScript environments:
|
|||||||
|
|
||||||
No runtime-specific APIs are used, making it truly portable.
|
No runtime-specific APIs are used, making it truly portable.
|
||||||
|
|
||||||
## Legal
|
## License and Legal Information
|
||||||
|
|
||||||
This project is licensed under MIT.
|
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](../license) file within this repository.
|
||||||
|
|
||||||
© 2025 Task Venture Capital GmbH. All rights reserved.
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
pnpm install --save-dev @git.zone/tstest
|
pnpm install --save-dev @git.zone/tstest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Issue Reporting and Security
|
||||||
|
|
||||||
|
For reporting bugs, issues, or security vulnerabilities, please visit https://community.foss.global/. This is the central community hub for all issue reporting. Developers who want to sign a contribution agreement and go through identification can also get a code.foss.global account to submit Pull Requests directly.
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
`@git.zone/tstest/tapbundle_serverside` provides server-side testing utilities exclusively for Node.js runtime. These tools enable shell command execution, environment variable management, HTTPS certificate generation, database testing, object storage testing, and test asset management - all functionality that only makes sense on the server-side.
|
`@git.zone/tstest/tapbundle_serverside` provides server-side testing utilities exclusively for Node.js runtime. These tools enable shell command execution, environment variable management, HTTPS certificate generation, database testing, object storage testing, and test asset management - all functionality that only makes sense on the server-side.
|
||||||
@@ -362,8 +366,21 @@ This module uses the following packages:
|
|||||||
- [@push.rocks/smartfile](https://code.foss.global/push.rocks/smartfile) - File operations
|
- [@push.rocks/smartfile](https://code.foss.global/push.rocks/smartfile) - File operations
|
||||||
- [@push.rocks/smartrequest](https://code.foss.global/push.rocks/smartrequest) - HTTP requests
|
- [@push.rocks/smartrequest](https://code.foss.global/push.rocks/smartrequest) - HTTP requests
|
||||||
|
|
||||||
## Legal
|
## License and Legal Information
|
||||||
|
|
||||||
This project is licensed under MIT.
|
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](../license) file within this repository.
|
||||||
|
|
||||||
© 2025 Task Venture Capital GmbH. All rights reserved.
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||||
|
|||||||
Reference in New Issue
Block a user