Compare commits

..

7 Commits

7 changed files with 1078 additions and 164 deletions

1
.serena/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/cache

View File

@@ -1,5 +1,28 @@
# Changelog
## 2025-09-12 - 2.3.8 - fix(tstest)
Improve free port selection for Chrome runner and bump smartnetwork dependency
- Use randomized port selection when finding free HTTP and WebSocket ports to reduce collision probability in concurrent runs
- Ensure WebSocket port search excludes the chosen HTTP port so the two ports will not conflict
- Simplify failure handling: throw early if a free WebSocket port cannot be found instead of retrying with a less robust fallback
- Bump @push.rocks/smartnetwork dependency from ^4.2.0 to ^4.4.0 to pick up new findFreePort options
## 2025-09-12 - 2.3.7 - fix(tests)
Remove flaky dynamic-ports browser test and add local dev tool settings
- Removed test/tapbundle/test.dynamicports.ts — deletes a browser test that relied on injected dynamic WebSocket ports (reduces flaky CI/browser runs).
- Added .claude/settings.local.json — local development settings for the CLAUDE helper (grants allowed dev/automation commands and webfetch permissions).
## 2025-09-03 - 2.3.6 - fix(tstest)
Update deps, fix chrome server route for static bundles, add local tool settings and CI ignore
- Bump devDependency @git.zone/tsbuild to ^2.6.8
- Bump dependencies: @api.global/typedserver to ^3.0.78, @push.rocks/smartlog to ^3.1.9, @push.rocks/smartrequest to ^4.3.1
- Fix test server static route in ts/tstest.classes.tstest.ts: replace '(.*)' with '/*splat' so bundled test files are served correctly in Chromium runs
- Add .claude/settings.local.json with local permissions for development tasks
- Add .serena/.gitignore to ignore /cache
## 2025-08-18 - 2.3.5 - fix(core)
Use SmartRequest with Buffer for binary downloads, tighten static route handling, bump dependencies and add workspace/config files

View File

@@ -1,6 +1,6 @@
{
"name": "@git.zone/tstest",
"version": "2.3.5",
"version": "2.3.8",
"private": false,
"description": "a test utility to run tests that match test/**/*.ts",
"exports": {
@@ -24,11 +24,11 @@
"buildDocs": "tsdoc"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.6.7",
"@git.zone/tsbuild": "^2.6.8",
"@types/node": "^22.15.21"
},
"dependencies": {
"@api.global/typedserver": "^3.0.77",
"@api.global/typedserver": "^3.0.78",
"@git.zone/tsbundle": "^2.5.1",
"@git.zone/tsrun": "^1.3.3",
"@push.rocks/consolecolor": "^2.0.3",
@@ -41,11 +41,12 @@
"@push.rocks/smartexpect": "^2.5.0",
"@push.rocks/smartfile": "^11.2.7",
"@push.rocks/smartjson": "^5.0.20",
"@push.rocks/smartlog": "^3.1.8",
"@push.rocks/smartlog": "^3.1.9",
"@push.rocks/smartmongo": "^2.0.12",
"@push.rocks/smartnetwork": "^4.4.0",
"@push.rocks/smartpath": "^6.0.0",
"@push.rocks/smartpromise": "^4.2.3",
"@push.rocks/smartrequest": "^4.2.2",
"@push.rocks/smartrequest": "^4.3.1",
"@push.rocks/smarts3": "^2.2.6",
"@push.rocks/smartshell": "^3.3.0",
"@push.rocks/smarttime": "^4.1.1",

1164
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: '2.3.5',
version: '2.3.8',
description: 'a test utility to run tests that match test/**/*.ts'
}

View File

@@ -316,6 +316,31 @@ import '${absoluteTestFile.replace(/\\/g, '/')}';
return tapParser;
}
private async findFreePorts(): Promise<{ httpPort: number; wsPort: number }> {
const smartnetwork = new plugins.smartnetwork.SmartNetwork();
// Find random free HTTP port in range 30000-40000 to minimize collision chance
const httpPort = await smartnetwork.findFreePort(30000, 40000, { randomize: true });
if (!httpPort) {
throw new Error('Could not find a free HTTP port in range 30000-40000');
}
// Find random free WebSocket port, excluding the HTTP port to ensure they're different
const wsPort = await smartnetwork.findFreePort(30000, 40000, {
randomize: true,
exclude: [httpPort]
});
if (!wsPort) {
throw new Error('Could not find a free WebSocket port in range 30000-40000');
}
// Log selected ports for debugging
if (!this.logger.options.quiet) {
console.log(`Selected ports - HTTP: ${httpPort}, WebSocket: ${wsPort}`);
}
return { httpPort, wsPort };
}
public async runInChrome(fileNameArg: string, index: number, total: number): Promise<TapParser> {
this.logger.testFileStart(fileNameArg, 'chromium', index, total);
@@ -330,10 +355,13 @@ import '${absoluteTestFile.replace(/\\/g, '/')}';
bundler: 'esbuild',
});
// Find free ports for HTTP and WebSocket
const { httpPort, wsPort } = await this.findFreePorts();
// lets create a server
const server = new plugins.typedserver.servertools.Server({
cors: true,
port: 3007,
port: httpPort,
});
server.addRoute(
'/test',
@@ -344,6 +372,7 @@ import '${absoluteTestFile.replace(/\\/g, '/')}';
<head>
<script>
globalThis.testdom = true;
globalThis.wsPort = ${wsPort};
</script>
</head>
<body></body>
@@ -352,12 +381,12 @@ import '${absoluteTestFile.replace(/\\/g, '/')}';
res.end();
})
);
server.addRoute('(.*)', new plugins.typedserver.servertools.HandlerStatic(tsbundleCacheDirPath));
server.addRoute('/*splat', new plugins.typedserver.servertools.HandlerStatic(tsbundleCacheDirPath));
await server.start();
// lets handle realtime comms
const tapParser = new TapParser(fileNameArg + ':chrome', this.logger);
const wss = new plugins.ws.WebSocketServer({ port: 8080 });
const wss = new plugins.ws.WebSocketServer({ port: wsPort });
wss.on('connection', (ws) => {
ws.on('message', (message) => {
const messageStr = message.toString();
@@ -374,10 +403,10 @@ import '${absoluteTestFile.replace(/\\/g, '/')}';
await this.smartbrowserInstance.start();
const evaluatePromise = this.smartbrowserInstance.evaluateOnPage(
`http://localhost:3007/test?bundleName=${bundleFileName}`,
`http://localhost:${httpPort}/test?bundleName=${bundleFileName}`,
async () => {
// lets enable real time comms
const ws = new WebSocket('ws://localhost:8080');
const ws = new WebSocket(`ws://localhost:${globalThis.wsPort}`);
await new Promise((resolve) => (ws.onopen = resolve));
// Ensure this function is declared with 'async'

View File

@@ -17,6 +17,7 @@ import * as smartchok from '@push.rocks/smartchok';
import * as smartdelay from '@push.rocks/smartdelay';
import * as smartfile from '@push.rocks/smartfile';
import * as smartlog from '@push.rocks/smartlog';
import * as smartnetwork from '@push.rocks/smartnetwork';
import * as smartpromise from '@push.rocks/smartpromise';
import * as smartshell from '@push.rocks/smartshell';
import * as tapbundle from '../dist_ts_tapbundle/index.js';
@@ -28,6 +29,7 @@ export {
smartdelay,
smartfile,
smartlog,
smartnetwork,
smartpromise,
smartshell,
tapbundle,