feat(tstest): Implement dynamic port allocation for HTTP and WebSocket connections, add tests for port validation
This commit is contained in:
		
							
								
								
									
										29
									
								
								test/tapbundle/test.dynamicports.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								test/tapbundle/test.dynamicports.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| import { tap, expect } from '../../ts_tapbundle/index.js'; | ||||
|  | ||||
| tap.test('should be running in browser with dynamic ports', async () => { | ||||
|   // Check that we're in a browser environment | ||||
|   expect(typeof window).toEqual('object'); | ||||
|   expect(typeof globalThis.testdom).toEqual('boolean'); | ||||
|   expect(globalThis.testdom).toBeTrue(); | ||||
|    | ||||
|   // Check that the WebSocket port was injected | ||||
|   expect(typeof globalThis.wsPort).toEqual('number'); | ||||
|   expect(globalThis.wsPort).toBeGreaterThan(29999); | ||||
|   expect(globalThis.wsPort).toBeLessThan(40001); | ||||
|    | ||||
|   console.log(`Browser test running with dynamic WebSocket port: ${globalThis.wsPort}`); | ||||
| }); | ||||
|  | ||||
| tap.test('should have different port than default 8080', async () => { | ||||
|   // The old hardcoded port was 8080, verify we're not using it | ||||
|   expect(globalThis.wsPort).not.toEqual(8080); | ||||
| }); | ||||
|  | ||||
| const testPromise = tap.start(); | ||||
|  | ||||
| // Export promise for browser compatibility | ||||
| if (typeof globalThis !== 'undefined') { | ||||
|   (globalThis as any).tapPromise = testPromise; | ||||
| } | ||||
|  | ||||
| export default testPromise; | ||||
		Reference in New Issue
	
	Block a user