diff --git a/clients/ts/FunctionalTests/ts/ConnectionTests.ts b/clients/ts/FunctionalTests/ts/ConnectionTests.ts index c62fd3f059..bfcb3d3252 100644 --- a/clients/ts/FunctionalTests/ts/ConnectionTests.ts +++ b/clients/ts/FunctionalTests/ts/ConnectionTests.ts @@ -10,6 +10,9 @@ const commonOptions: IHttpConnectionOptions = { logger: TestLogger.instance, }; +// On slower CI machines, these tests sometimes take longer than 5s +jasmine.DEFAULT_TIMEOUT_INTERVAL = 10 * 1000; + describe("connection", () => { it("can connect to the server without specifying transport explicitly", (done) => { const message = "Hello World!"; @@ -88,7 +91,7 @@ describe("connection", () => { connection.onclose = (error) => { // Search the logs for the message content expect(TestLogger.instance.currentLog.messages.length).toBeGreaterThan(0); - for (const [_, logMessage] of TestLogger.instance.currentLog.messages) { + for (const [_, __, logMessage] of TestLogger.instance.currentLog.messages) { expect(logMessage).not.toContain(message); } done(); @@ -122,7 +125,7 @@ describe("connection", () => { // Search the logs for the message content let matches = 0; expect(TestLogger.instance.currentLog.messages.length).toBeGreaterThan(0); - for (const [_, logMessage] of TestLogger.instance.currentLog.messages) { + for (const [_, __, logMessage] of TestLogger.instance.currentLog.messages) { if (logMessage.indexOf(message) !== -1) { matches += 1; } diff --git a/clients/ts/FunctionalTests/ts/HubConnectionTests.ts b/clients/ts/FunctionalTests/ts/HubConnectionTests.ts index e44367c27f..f99a05aedd 100644 --- a/clients/ts/FunctionalTests/ts/HubConnectionTests.ts +++ b/clients/ts/FunctionalTests/ts/HubConnectionTests.ts @@ -15,6 +15,9 @@ const commonOptions: IHubConnectionOptions = { logger: TestLogger.instance, }; +// On slower CI machines, these tests sometimes take longer than 5s +jasmine.DEFAULT_TIMEOUT_INTERVAL = 10 * 1000; + describe("hubConnection", () => { eachTransportAndProtocol((transportType, protocol) => { describe("using " + protocol.name + " over " + TransportType[transportType] + " transport", () => { @@ -27,7 +30,7 @@ describe("hubConnection", () => { transport: transportType, }); hubConnection.onclose((error) => { - expect(error).toBe(undefined); + expect(error).toBeUndefined(); done(); }); diff --git a/clients/ts/FunctionalTests/ts/TestLogger.ts b/clients/ts/FunctionalTests/ts/TestLogger.ts index 81ed67ae7d..8c73651127 100644 --- a/clients/ts/FunctionalTests/ts/TestLogger.ts +++ b/clients/ts/FunctionalTests/ts/TestLogger.ts @@ -1,17 +1,17 @@ import { ConsoleLogger, ILogger, LogLevel } from "@aspnet/signalr"; export class TestLog { - public messages: Array<[LogLevel, string]> = []; + public messages: Array<[Date, LogLevel, string]> = []; - public addMessage(logLevel: LogLevel, message: string): void { - this.messages.push([logLevel, message]); + public addMessage(timestamp: Date, logLevel: LogLevel, message: string): void { + this.messages.push([timestamp, logLevel, message]); } public getLog(): string { // Dump the logs to a string let str = ""; - for (const [level, message] of this.messages) { - str += `${LogLevel[level]}: ${message}\r\n`; + for (const [timestamp, level, message] of this.messages) { + str += `[${timestamp.toISOString()}] ${LogLevel[level]}: ${message}\r\n`; } return str; @@ -34,7 +34,7 @@ export class TestLogger implements ILogger { public currentLog: TestLog = new TestLog(); public log(logLevel: LogLevel, message: string): void { - this.currentLog.addMessage(logLevel, message); + this.currentLog.addMessage(new Date(), logLevel, message); // Also write to browser console TestLogger.consoleLogger.log(logLevel, message); diff --git a/clients/ts/FunctionalTests/ts/WebDriverReporter.ts b/clients/ts/FunctionalTests/ts/WebDriverReporter.ts index f6449f1f18..a768150521 100644 --- a/clients/ts/FunctionalTests/ts/WebDriverReporter.ts +++ b/clients/ts/FunctionalTests/ts/WebDriverReporter.ts @@ -76,8 +76,9 @@ class WebDriverReporter implements jasmine.CustomReporter { // Report log messages if (testLog.messages.length > 0) { this.taplog(" - logs: "); - for (const [level, message] of testLog.messages) { + for (const [timestamp, level, message] of testLog.messages) { this.taplog(` - level: ${LogLevel[level]}`); + this.taplog(` timestamp: ${timestamp.toISOString()}`); this.taplog(` message: ${message}`); } } diff --git a/clients/ts/FunctionalTests/ts/WebSocketTests.ts b/clients/ts/FunctionalTests/ts/WebSocketTests.ts index e70e322d57..8266e3ffdc 100644 --- a/clients/ts/FunctionalTests/ts/WebSocketTests.ts +++ b/clients/ts/FunctionalTests/ts/WebSocketTests.ts @@ -3,6 +3,9 @@ import { ECHOENDPOINT_URL } from "./Common"; +// On slower CI machines, these tests sometimes take longer than 5s +jasmine.DEFAULT_TIMEOUT_INTERVAL = 10 * 1000; + if (typeof WebSocket !== "undefined") { describe("WebSockets", () => { it("can be used to connect to SignalR", (done) => {