increase jasmine timeout and add timestamps to logs (#1959)
This commit is contained in:
parent
8cc851ff9b
commit
ee6e8c15ce
|
|
@ -10,6 +10,9 @@ const commonOptions: IHttpConnectionOptions = {
|
||||||
logger: TestLogger.instance,
|
logger: TestLogger.instance,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// On slower CI machines, these tests sometimes take longer than 5s
|
||||||
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10 * 1000;
|
||||||
|
|
||||||
describe("connection", () => {
|
describe("connection", () => {
|
||||||
it("can connect to the server without specifying transport explicitly", (done) => {
|
it("can connect to the server without specifying transport explicitly", (done) => {
|
||||||
const message = "Hello World!";
|
const message = "Hello World!";
|
||||||
|
|
@ -88,7 +91,7 @@ describe("connection", () => {
|
||||||
connection.onclose = (error) => {
|
connection.onclose = (error) => {
|
||||||
// Search the logs for the message content
|
// Search the logs for the message content
|
||||||
expect(TestLogger.instance.currentLog.messages.length).toBeGreaterThan(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) {
|
||||||
expect(logMessage).not.toContain(message);
|
expect(logMessage).not.toContain(message);
|
||||||
}
|
}
|
||||||
done();
|
done();
|
||||||
|
|
@ -122,7 +125,7 @@ describe("connection", () => {
|
||||||
// Search the logs for the message content
|
// Search the logs for the message content
|
||||||
let matches = 0;
|
let matches = 0;
|
||||||
expect(TestLogger.instance.currentLog.messages.length).toBeGreaterThan(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) {
|
if (logMessage.indexOf(message) !== -1) {
|
||||||
matches += 1;
|
matches += 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,9 @@ const commonOptions: IHubConnectionOptions = {
|
||||||
logger: TestLogger.instance,
|
logger: TestLogger.instance,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// On slower CI machines, these tests sometimes take longer than 5s
|
||||||
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10 * 1000;
|
||||||
|
|
||||||
describe("hubConnection", () => {
|
describe("hubConnection", () => {
|
||||||
eachTransportAndProtocol((transportType, protocol) => {
|
eachTransportAndProtocol((transportType, protocol) => {
|
||||||
describe("using " + protocol.name + " over " + TransportType[transportType] + " transport", () => {
|
describe("using " + protocol.name + " over " + TransportType[transportType] + " transport", () => {
|
||||||
|
|
@ -27,7 +30,7 @@ describe("hubConnection", () => {
|
||||||
transport: transportType,
|
transport: transportType,
|
||||||
});
|
});
|
||||||
hubConnection.onclose((error) => {
|
hubConnection.onclose((error) => {
|
||||||
expect(error).toBe(undefined);
|
expect(error).toBeUndefined();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
import { ConsoleLogger, ILogger, LogLevel } from "@aspnet/signalr";
|
import { ConsoleLogger, ILogger, LogLevel } from "@aspnet/signalr";
|
||||||
|
|
||||||
export class TestLog {
|
export class TestLog {
|
||||||
public messages: Array<[LogLevel, string]> = [];
|
public messages: Array<[Date, LogLevel, string]> = [];
|
||||||
|
|
||||||
public addMessage(logLevel: LogLevel, message: string): void {
|
public addMessage(timestamp: Date, logLevel: LogLevel, message: string): void {
|
||||||
this.messages.push([logLevel, message]);
|
this.messages.push([timestamp, logLevel, message]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getLog(): string {
|
public getLog(): string {
|
||||||
// Dump the logs to a string
|
// Dump the logs to a string
|
||||||
let str = "";
|
let str = "";
|
||||||
for (const [level, message] of this.messages) {
|
for (const [timestamp, level, message] of this.messages) {
|
||||||
str += `${LogLevel[level]}: ${message}\r\n`;
|
str += `[${timestamp.toISOString()}] ${LogLevel[level]}: ${message}\r\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
|
|
@ -34,7 +34,7 @@ export class TestLogger implements ILogger {
|
||||||
public currentLog: TestLog = new TestLog();
|
public currentLog: TestLog = new TestLog();
|
||||||
|
|
||||||
public log(logLevel: LogLevel, message: string): void {
|
public log(logLevel: LogLevel, message: string): void {
|
||||||
this.currentLog.addMessage(logLevel, message);
|
this.currentLog.addMessage(new Date(), logLevel, message);
|
||||||
|
|
||||||
// Also write to browser console
|
// Also write to browser console
|
||||||
TestLogger.consoleLogger.log(logLevel, message);
|
TestLogger.consoleLogger.log(logLevel, message);
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,9 @@ class WebDriverReporter implements jasmine.CustomReporter {
|
||||||
// Report log messages
|
// Report log messages
|
||||||
if (testLog.messages.length > 0) {
|
if (testLog.messages.length > 0) {
|
||||||
this.taplog(" - logs: ");
|
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(` - level: ${LogLevel[level]}`);
|
||||||
|
this.taplog(` timestamp: ${timestamp.toISOString()}`);
|
||||||
this.taplog(` message: ${message}`);
|
this.taplog(` message: ${message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
import { ECHOENDPOINT_URL } from "./Common";
|
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") {
|
if (typeof WebSocket !== "undefined") {
|
||||||
describe("WebSockets", () => {
|
describe("WebSockets", () => {
|
||||||
it("can be used to connect to SignalR", (done) => {
|
it("can be used to connect to SignalR", (done) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue