Files
tstest/test/tapbundle/test.dynamicports.ts

29 lines
1008 B
TypeScript

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;