fix(tapbundle_serverside): add TapNodeTools cleanup hooks to stop SmartNetwork processes after tests

This commit is contained in:
2026-03-27 18:23:42 +00:00
parent 7490da22c0
commit 2946169360
10 changed files with 151 additions and 152 deletions

View File

@@ -30,8 +30,11 @@ For reporting bugs, issues, or security vulnerabilities, please visit [community
## Basic Usage
```typescript
import { tapNodeTools } from '@git.zone/tstest/tapbundle_serverside';
import { tap, expect } from '@git.zone/tstest/tapbundle';
import { TapNodeTools } from '@git.zone/tstest/tapbundle_serverside';
// Create an instance and pass `tap` so cleanup is automatic
const tapNodeTools = new TapNodeTools(tap);
tap.test('should start server on free port', async () => {
const port = await tapNodeTools.findFreePort();
@@ -41,11 +44,15 @@ tap.test('should start server on free port', async () => {
export default tap.start();
```
### How cleanup works
`TapNodeTools` accepts any object with a `registerCleanup()` method (the `tap` instance). On construction, it registers a cleanup callback that stops long-lived background processes (e.g. the SmartNetwork Rust bridge). When `tap.start()` finishes running all tests, it calls all registered cleanup functions automatically, so the Node.js event loop can drain and the process exits cleanly.
## API Reference
### tapNodeTools
### TapNodeTools
The main singleton instance providing all Node.js-specific utilities.
Construct with a `tap` instance to enable automatic cleanup:
---