fix(tapbundle): treat tests that call tools.allowFailure() as passing and update tests to use tools parameter

This commit is contained in:
2026-01-25 22:20:14 +00:00
parent d92850e1d2
commit fdc84a2d83
6 changed files with 17 additions and 7 deletions

View File

@@ -1,5 +1,12 @@
# Changelog # Changelog
## 2026-01-25 - 3.1.8 - fix(tapbundle)
treat tests that call tools.allowFailure() as passing and update tests to use tools parameter
- Set testResult.ok to this.failureAllowed so allowed failures are considered passing in the tap test runner implementation (ts_tapbundle/tapbundle.classes.taptest.ts).
- Updated multiple tests to accept the tools parameter and call tools.allowFailure() where failures are intended (test/tapbundle/test.performance-metrics.ts, test/tstest/test.fail.ts, test/tstest/test.failing-with-logs.ts).
- Prevents intentionally-failing tests from skewing timing/metric calculations and preserves console logs for allowed failures.
## 2026-01-25 - 3.1.7 - fix(tap-parser) ## 2026-01-25 - 3.1.7 - fix(tap-parser)
append newline to WebSocket tap log messages to ensure proper line-by-line processing append newline to WebSocket tap log messages to ensure proper line-by-line processing

View File

@@ -47,6 +47,7 @@ tap.test('metric test fast 3 - minimal work', async () => {
// Test to verify that failed tests still contribute to timing metrics // Test to verify that failed tests still contribute to timing metrics
tap.test('metric test that fails - 60ms before failure', async (tools) => { tap.test('metric test that fails - 60ms before failure', async (tools) => {
tools.allowFailure();
await tools.delayFor(60); await tools.delayFor(60);
expect(true).toBeFalse(); // This will fail expect(true).toBeFalse(); // This will fail
}); });

View File

@@ -1,6 +1,7 @@
import { expect, tap } from '../../ts_tapbundle/index.js'; import { expect, tap } from '../../ts_tapbundle/index.js';
tap.test('This test should fail', async () => { tap.test('This test should fail', async (tools) => {
tools.allowFailure();
console.log('This test will fail on purpose'); console.log('This test will fail on purpose');
expect(true).toBeFalse(); expect(true).toBeFalse();
}); });

View File

@@ -1,6 +1,7 @@
import { expect, tap } from '../../ts_tapbundle/index.js'; import { expect, tap } from '../../ts_tapbundle/index.js';
tap.test('Test that will fail with console logs', async () => { tap.test('Test that will fail with console logs', async (tools) => {
tools.allowFailure();
console.log('Starting the test...'); console.log('Starting the test...');
console.log('Doing some setup work'); console.log('Doing some setup work');
console.log('About to check assertion'); console.log('About to check assertion');

View File

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

View File

@@ -261,7 +261,7 @@ export class TapTest<T = unknown> {
// Final failure // Final failure
const testResult = { const testResult = {
ok: false, ok: this.failureAllowed, // Pass if failure is allowed
testNumber, testNumber,
description: this.description, description: this.description,
metadata: { metadata: {