fix(tstest): Fix test timing display issue and update TAP protocol documentation

This commit is contained in:
2025-05-23 22:27:12 +00:00
parent 02aeb8195e
commit c48887a820
9 changed files with 1041 additions and 211 deletions

View File

@@ -74,4 +74,34 @@ This fix ensures that test files with the same basename in different directories
1. Takes the relative path from the current working directory
2. Replaces path separators (`/`) with double underscores (`__`)
3. Removes the `.ts` extension
4. Creates a flat filename that preserves the directory structure
4. Creates a flat filename that preserves the directory structure
### Test Timing Display (Fixed in v1.9.2)
Fixed an issue where test timing was displayed incorrectly with duplicate values like:
- Before: `✅ test name # time=133ms (0ms)`
- After: `✅ test name (133ms)`
The issue was in the TAP parser regex which was greedily capturing the entire line including the TAP timing comment. Changed the regex from `(.*)` to `(.*?)` to make it non-greedy, properly separating the test name from the timing metadata.
## Protocol Limitations and Improvements
### Current TAP Protocol Issues
The current implementation uses standard TAP format with metadata in comments:
```
ok 1 - test name # time=123ms
```
This has several limitations:
1. **Delimiter Conflict**: Test descriptions containing `#` can break parsing
2. **Regex Fragility**: Complex regex patterns that are hard to maintain
3. **Limited Metadata**: Difficult to add rich error information or custom data
### Planned Protocol V2
A new internal protocol is being designed that will:
- Use Unicode delimiters `⟦TSTEST:⟧` that won't conflict with test content
- Support structured JSON metadata
- Allow rich error reporting with stack traces and diffs
- Maintain backwards compatibility during migration
See `readme.protocol.md` for the full specification and `tapbundle.protocols.ts` for the implementation utilities.