Compare commits

..

10 Commits

Author SHA1 Message Date
3655b2f734 1.0.88 2024-03-07 13:17:29 +01:00
6712ff6b07 fix(core): update 2024-03-07 13:17:28 +01:00
ef5efc0a93 1.0.87 2024-03-07 13:10:58 +01:00
f305547116 fix(core): update 2024-03-07 13:10:57 +01:00
033a0a806c 1.0.86 2024-01-19 20:59:02 +01:00
7f87c24ad8 fix(core): update 2024-01-19 20:59:01 +01:00
ac08bdffe5 1.0.85 2023-11-10 12:44:08 +01:00
eb64cb4f71 fix(core): update 2023-11-10 12:44:08 +01:00
3b56c6ce9f 1.0.84 2023-11-09 21:06:07 +01:00
722d777f80 fix(core): update 2023-11-09 21:06:06 +01:00
6 changed files with 447 additions and 332 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@git.zone/tstest",
"version": "1.0.83",
"version": "1.0.88",
"private": false,
"description": "a test utility to run tests that match test/**/*.ts",
"main": "dist_ts/index.js",
@ -20,24 +20,24 @@
"buildDocs": "tsdoc"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.1.70",
"@types/node": "^20.9.0"
"@git.zone/tsbuild": "^2.1.72",
"@types/node": "^20.11.25"
},
"dependencies": {
"@api.global/typedserver": "^3.0.9",
"@git.zone/tsbundle": "^2.0.10",
"@api.global/typedserver": "^3.0.27",
"@git.zone/tsbundle": "^2.0.15",
"@git.zone/tsrun": "^1.2.46",
"@push.rocks/consolecolor": "^2.0.1",
"@push.rocks/smartbrowser": "^2.0.6",
"@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartfile": "^11.0.0",
"@push.rocks/smartfile": "^11.0.4",
"@push.rocks/smartlog": "^3.0.3",
"@push.rocks/smartpromise": "^4.0.3",
"@push.rocks/smartshell": "^3.0.3",
"@push.rocks/tapbundle": "^5.0.15",
"@types/ws": "^8.5.9",
"figures": "^6.0.1",
"ws": "^8.14.2"
"@types/ws": "^8.5.10",
"figures": "^6.1.0",
"ws": "^8.16.0"
},
"files": [
"ts/**/*",

730
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -18,6 +18,8 @@ export class TapParser {
testStatusRegex = /(ok|not\sok)\s([0-9]+)\s-\s(.*)\s#\stime=(.*)ms$/;
activeTapTestResult: TapTestResult;
pretaskRegex = /^::__PRETASK:(.*)$/;
/**
* the constructor for TapParser
*/
@ -49,6 +51,12 @@ export class TapParser {
// initiating first TapResult
this._getNewTapTestResult();
} else if (this.pretaskRegex.test(logLine)) {
logLineIsTapProtocol = true;
const pretaskContentMatch = this.pretaskRegex.exec(logLine);
if (pretaskContentMatch && pretaskContentMatch[1]) {
console.log(`${logPrefixes.TapPretaskPrefix} Pretask ->${pretaskContentMatch[1]}: Success.`);
}
} else if (this.testStatusRegex.test(logLine)) {
logLineIsTapProtocol = true;
const regexResult = this.testStatusRegex.exec(logLine);
@ -149,7 +157,7 @@ export class TapParser {
this._processLog(data);
});
childProcessArg.on('exit', async () => {
await this._evaluateResult();
await this.evaluateFinalResult();
done.resolve();
});
await done.promise;
@ -157,10 +165,9 @@ export class TapParser {
public async handleTapLog(tapLog: string) {
this._processLog(tapLog);
await this._evaluateResult();
}
private async _evaluateResult() {
public async evaluateFinalResult() {
this.receivedTests = this.testStore.length;
// check wether all tests ran

View File

@ -130,10 +130,11 @@ export class TsTest {
await server.start();
// lets handle realtime comms
const tapParser = new TapParser(fileNameArg + ':chrome');
const wss = new plugins.ws.WebSocketServer({ port: 8080 });
wss.on('connection', (ws) => {
ws.on('message', (message) => {
console.log(message.toString());
tapParser.handleTapLog(message.toString());
});
});
@ -169,14 +170,14 @@ export class TsTest {
try {
// Dynamically import the test module
const testModule = await import(`/${bundleName}`);
if (testModule && testModule.runTest) {
if (testModule && testModule.runTestPromise) {
// Execute the exported test function
await testModule.runTest();
await testModule.runTestPromise;
} else {
originalError('Test module does not export runTest function.');
console.error('Test module does not export runTest function.');
}
} catch (err) {
originalError(err);
console.error(err);
}
return logStore.join('\n');
@ -188,10 +189,8 @@ export class TsTest {
console.log(
`${cs('=> ', 'blue')} Stopped ${cs(fileNameArg, 'orange')} chromium instance and server.`
);
console.log(`${cs('=> ', 'blue')} See the result captured from the chromium execution:`);
// lets create the tap parser
const tapParser = new TapParser(fileNameArg + ':chrome');
tapParser.handleTapLog(evaluation);
await tapParser.evaluateFinalResult();
return tapParser;
}

View File

@ -2,6 +2,7 @@ import * as plugins from './tstest.plugins.js';
import { coloredString as cs } from '@push.rocks/consolecolor';
export const TapPrefix = cs(`::TAP::`, 'pink', 'black');
export const TapPretaskPrefix = cs(`::PRETASK::`, 'cyan', 'black');
export const TapErrorPrefix = cs(` !!!TAP PROTOCOL ERROR!!! `, 'red', 'black');
export const TsTestPrefix = cs(`**TSTEST**`, 'pink', 'black');