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,
|
||||
};
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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}`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue