Compare commits

...

5 Commits

7 changed files with 796 additions and 179 deletions

1
.serena/.gitignore vendored Normal file
View File

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

View File

@@ -1,5 +1,20 @@
# Changelog # Changelog
## 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) ## 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 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", "name": "@git.zone/tstest",
"version": "2.3.5", "version": "2.3.7",
"private": false, "private": false,
"description": "a test utility to run tests that match test/**/*.ts", "description": "a test utility to run tests that match test/**/*.ts",
"exports": { "exports": {
@@ -24,11 +24,11 @@
"buildDocs": "tsdoc" "buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.6.7", "@git.zone/tsbuild": "^2.6.8",
"@types/node": "^22.15.21" "@types/node": "^22.15.21"
}, },
"dependencies": { "dependencies": {
"@api.global/typedserver": "^3.0.77", "@api.global/typedserver": "^3.0.78",
"@git.zone/tsbundle": "^2.5.1", "@git.zone/tsbundle": "^2.5.1",
"@git.zone/tsrun": "^1.3.3", "@git.zone/tsrun": "^1.3.3",
"@push.rocks/consolecolor": "^2.0.3", "@push.rocks/consolecolor": "^2.0.3",
@@ -41,11 +41,12 @@
"@push.rocks/smartexpect": "^2.5.0", "@push.rocks/smartexpect": "^2.5.0",
"@push.rocks/smartfile": "^11.2.7", "@push.rocks/smartfile": "^11.2.7",
"@push.rocks/smartjson": "^5.0.20", "@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/smartmongo": "^2.0.12",
"@push.rocks/smartnetwork": "^4.2.0",
"@push.rocks/smartpath": "^6.0.0", "@push.rocks/smartpath": "^6.0.0",
"@push.rocks/smartpromise": "^4.2.3", "@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/smarts3": "^2.2.6",
"@push.rocks/smartshell": "^3.3.0", "@push.rocks/smartshell": "^3.3.0",
"@push.rocks/smarttime": "^4.1.1", "@push.rocks/smarttime": "^4.1.1",

904
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -316,6 +316,32 @@ import '${absoluteTestFile.replace(/\\/g, '/')}';
return tapParser; return tapParser;
} }
private async findFreePorts(): Promise<{ httpPort: number; wsPort: number }> {
const smartnetwork = new plugins.smartnetwork.SmartNetwork();
// Find HTTP port in range 30000-40000
const httpPort = await smartnetwork.findFreePort(30000, 40000);
if (!httpPort) {
throw new Error('Could not find a free HTTP port in range 30000-40000');
}
// Find WebSocket port in range 30000-40000 (different from HTTP port)
let wsPort = await smartnetwork.findFreePort(httpPort + 1, 40000);
if (!wsPort) {
// Try again from the beginning of the range if we couldn't find one after httpPort
wsPort = await smartnetwork.findFreePort(30000, httpPort - 1);
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> { public async runInChrome(fileNameArg: string, index: number, total: number): Promise<TapParser> {
this.logger.testFileStart(fileNameArg, 'chromium', index, total); this.logger.testFileStart(fileNameArg, 'chromium', index, total);
@@ -330,10 +356,13 @@ import '${absoluteTestFile.replace(/\\/g, '/')}';
bundler: 'esbuild', bundler: 'esbuild',
}); });
// Find free ports for HTTP and WebSocket
const { httpPort, wsPort } = await this.findFreePorts();
// lets create a server // lets create a server
const server = new plugins.typedserver.servertools.Server({ const server = new plugins.typedserver.servertools.Server({
cors: true, cors: true,
port: 3007, port: httpPort,
}); });
server.addRoute( server.addRoute(
'/test', '/test',
@@ -344,6 +373,7 @@ import '${absoluteTestFile.replace(/\\/g, '/')}';
<head> <head>
<script> <script>
globalThis.testdom = true; globalThis.testdom = true;
globalThis.wsPort = ${wsPort};
</script> </script>
</head> </head>
<body></body> <body></body>
@@ -352,12 +382,12 @@ import '${absoluteTestFile.replace(/\\/g, '/')}';
res.end(); res.end();
}) })
); );
server.addRoute('(.*)', new plugins.typedserver.servertools.HandlerStatic(tsbundleCacheDirPath)); server.addRoute('/*splat', new plugins.typedserver.servertools.HandlerStatic(tsbundleCacheDirPath));
await server.start(); await server.start();
// lets handle realtime comms // lets handle realtime comms
const tapParser = new TapParser(fileNameArg + ':chrome', this.logger); 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) => { wss.on('connection', (ws) => {
ws.on('message', (message) => { ws.on('message', (message) => {
const messageStr = message.toString(); const messageStr = message.toString();
@@ -374,10 +404,10 @@ import '${absoluteTestFile.replace(/\\/g, '/')}';
await this.smartbrowserInstance.start(); await this.smartbrowserInstance.start();
const evaluatePromise = this.smartbrowserInstance.evaluateOnPage( const evaluatePromise = this.smartbrowserInstance.evaluateOnPage(
`http://localhost:3007/test?bundleName=${bundleFileName}`, `http://localhost:${httpPort}/test?bundleName=${bundleFileName}`,
async () => { async () => {
// lets enable real time comms // 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)); await new Promise((resolve) => (ws.onopen = resolve));
// Ensure this function is declared with 'async' // 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 smartdelay from '@push.rocks/smartdelay';
import * as smartfile from '@push.rocks/smartfile'; import * as smartfile from '@push.rocks/smartfile';
import * as smartlog from '@push.rocks/smartlog'; import * as smartlog from '@push.rocks/smartlog';
import * as smartnetwork from '@push.rocks/smartnetwork';
import * as smartpromise from '@push.rocks/smartpromise'; import * as smartpromise from '@push.rocks/smartpromise';
import * as smartshell from '@push.rocks/smartshell'; import * as smartshell from '@push.rocks/smartshell';
import * as tapbundle from '../dist_ts_tapbundle/index.js'; import * as tapbundle from '../dist_ts_tapbundle/index.js';
@@ -28,6 +29,7 @@ export {
smartdelay, smartdelay,
smartfile, smartfile,
smartlog, smartlog,
smartnetwork,
smartpromise, smartpromise,
smartshell, smartshell,
tapbundle, tapbundle,