fix(TsTest): Fixed improper type-check for promise-like testModule defaults

This commit is contained in:
Philipp Kunz 2025-01-23 20:03:52 +01:00
parent 962fa2cd4d
commit 90741ed917
3 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## 2025-01-23 - 1.0.96 - fix(TsTest)
Fixed improper type-check for promise-like testModule defaults
- Corrected the type-check for promise-like default exports in test modules
- Removed unnecessary setTimeout used for async execution
## 2025-01-23 - 1.0.95 - fix(core) ## 2025-01-23 - 1.0.95 - fix(core)
Fix delay handling in Chrome test execution Fix delay handling in Chrome test execution

View File

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

View File

@ -170,16 +170,15 @@ export class TsTest {
try { try {
// Dynamically import the test module // Dynamically import the test module
const testModule = await import(`/${bundleName}`); const testModule = await import(`/${bundleName}`);
await new Promise(resolve => setTimeout(resolve, 0));
if (testModule && testModule.default && testModule.default instanceof Promise) { if (testModule && testModule.default && testModule.default instanceof Promise) {
// Execute the exported test function // Execute the exported test function
await testModule.default; await testModule.default;
} else if (testModule && testModule.default && testModule.default.then === 'function') { } else if (testModule && testModule.default && typeof testModule.default.then === 'function') {
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
console.log('Test module default export is just promiselike: Something might be messing with your Promise implementation.'); console.log('Test module default export is just promiselike: Something might be messing with your Promise implementation.');
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
await testModule.default; await testModule.default;
} else if (globalThis.tapPromise && globalThis.tapPromise.then === 'function') { } else if (globalThis.tapPromise && typeof globalThis.tapPromise.then === 'function') {
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
console.log('Using globalThis.tapPromise'); console.log('Using globalThis.tapPromise');
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');