From fdc84a2d8374baefec9d73e2c64888c44ec9b7ed Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Sun, 25 Jan 2026 22:20:14 +0000 Subject: [PATCH] fix(tapbundle): treat tests that call tools.allowFailure() as passing and update tests to use tools parameter --- changelog.md | 7 +++++++ test/tapbundle/test.performance-metrics.ts | 1 + test/tstest/test.fail.ts | 3 ++- test/tstest/test.failing-with-logs.ts | 9 +++++---- ts/00_commitinfo_data.ts | 2 +- ts_tapbundle/tapbundle.classes.taptest.ts | 2 +- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/changelog.md b/changelog.md index 0549304..acdb50f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # 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) append newline to WebSocket tap log messages to ensure proper line-by-line processing diff --git a/test/tapbundle/test.performance-metrics.ts b/test/tapbundle/test.performance-metrics.ts index c8da93f..daa101a 100644 --- a/test/tapbundle/test.performance-metrics.ts +++ b/test/tapbundle/test.performance-metrics.ts @@ -47,6 +47,7 @@ tap.test('metric test fast 3 - minimal work', async () => { // Test to verify that failed tests still contribute to timing metrics tap.test('metric test that fails - 60ms before failure', async (tools) => { + tools.allowFailure(); await tools.delayFor(60); expect(true).toBeFalse(); // This will fail }); diff --git a/test/tstest/test.fail.ts b/test/tstest/test.fail.ts index 3c6c8fd..83da916 100644 --- a/test/tstest/test.fail.ts +++ b/test/tstest/test.fail.ts @@ -1,6 +1,7 @@ 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'); expect(true).toBeFalse(); }); diff --git a/test/tstest/test.failing-with-logs.ts b/test/tstest/test.failing-with-logs.ts index 30d969c..a61d811 100644 --- a/test/tstest/test.failing-with-logs.ts +++ b/test/tstest/test.failing-with-logs.ts @@ -1,16 +1,17 @@ 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('Doing some setup work'); console.log('About to check assertion'); - + const value = 42; console.log(`The value is: ${value}`); - + // This will fail expect(value).toEqual(100); - + console.log('This log will not be reached'); }); diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index af3e717..7a67796 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/tstest', - version: '3.1.7', + version: '3.1.8', description: 'a test utility to run tests that match test/**/*.ts' } diff --git a/ts_tapbundle/tapbundle.classes.taptest.ts b/ts_tapbundle/tapbundle.classes.taptest.ts index c946bcf..17f7880 100644 --- a/ts_tapbundle/tapbundle.classes.taptest.ts +++ b/ts_tapbundle/tapbundle.classes.taptest.ts @@ -261,7 +261,7 @@ export class TapTest { // Final failure const testResult = { - ok: false, + ok: this.failureAllowed, // Pass if failure is allowed testNumber, description: this.description, metadata: {