Log unhandled exceptions to help see errors in tests (#2815)
This commit is contained in:
parent
b981e24a53
commit
3b853daa1a
|
|
@ -2,6 +2,9 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { AbortController } from "../src/AbortController";
|
||||
import { registerUnhandledRejectionHandler } from "./Utils";
|
||||
|
||||
registerUnhandledRejectionHandler();
|
||||
|
||||
describe("AbortSignal", () => {
|
||||
describe("aborted", () => {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
import { HttpRequest } from "../src/HttpClient";
|
||||
import { TestHttpClient } from "./TestHttpClient";
|
||||
import { registerUnhandledRejectionHandler } from "./Utils";
|
||||
|
||||
registerUnhandledRejectionHandler();
|
||||
|
||||
describe("HttpClient", () => {
|
||||
describe("get", () => {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import { EventSourceConstructor, WebSocketConstructor } from "../src/Polyfills";
|
|||
|
||||
import { eachEndpointUrl, eachTransport, VerifyLogger } from "./Common";
|
||||
import { TestHttpClient } from "./TestHttpClient";
|
||||
import { PromiseSource } from "./Utils";
|
||||
import { PromiseSource, registerUnhandledRejectionHandler } from "./Utils";
|
||||
|
||||
const commonOptions: IHttpConnectionOptions = {
|
||||
logger: NullLogger.instance,
|
||||
|
|
@ -28,6 +28,8 @@ const defaultNegotiateResponse: INegotiateResponse = {
|
|||
connectionId: defaultConnectionId,
|
||||
};
|
||||
|
||||
registerUnhandledRejectionHandler();
|
||||
|
||||
describe("HttpConnection", () => {
|
||||
it("cannot be created with relative url if document object is not present", () => {
|
||||
expect(() => new HttpConnection("/test", commonOptions))
|
||||
|
|
|
|||
|
|
@ -12,12 +12,14 @@ import { IStreamSubscriber } from "../src/Stream";
|
|||
import { TextMessageFormat } from "../src/TextMessageFormat";
|
||||
|
||||
import { VerifyLogger } from "./Common";
|
||||
import { delay, PromiseSource } from "./Utils";
|
||||
import { delay, PromiseSource, registerUnhandledRejectionHandler } from "./Utils";
|
||||
|
||||
function createHubConnection(connection: IConnection, logger?: ILogger | null, protocol?: IHubProtocol | null) {
|
||||
return HubConnection.create(connection, logger || NullLogger.instance, protocol || new JsonHubProtocol());
|
||||
}
|
||||
|
||||
registerUnhandledRejectionHandler();
|
||||
|
||||
describe("HubConnection", () => {
|
||||
|
||||
describe("start", () => {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import { NullLogger } from "../src/Loggers";
|
|||
|
||||
import { VerifyLogger } from "./Common";
|
||||
import { TestHttpClient } from "./TestHttpClient";
|
||||
import { PromiseSource } from "./Utils";
|
||||
import { PromiseSource, registerUnhandledRejectionHandler } from "./Utils";
|
||||
|
||||
const longPollingNegotiateResponse = {
|
||||
availableTransports: [
|
||||
|
|
@ -25,6 +25,8 @@ const commonHttpOptions: IHttpConnectionOptions = {
|
|||
logMessageContent: true,
|
||||
};
|
||||
|
||||
registerUnhandledRejectionHandler();
|
||||
|
||||
describe("HubConnectionBuilder", () => {
|
||||
eachMissingValue((val, name) => {
|
||||
it(`configureLogging throws if logger is ${name}`, () => {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import { CompletionMessage, InvocationMessage, MessageType, StreamItemMessage }
|
|||
import { JsonHubProtocol } from "../src/JsonHubProtocol";
|
||||
import { TextMessageFormat } from "../src/TextMessageFormat";
|
||||
import { VerifyLogger } from "./Common";
|
||||
import { registerUnhandledRejectionHandler } from "./Utils";
|
||||
|
||||
registerUnhandledRejectionHandler();
|
||||
|
||||
describe("JsonHubProtocol", () => {
|
||||
it("can write/read non-blocking Invocation message", async () => {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@ import { LongPollingTransport } from "../src/LongPollingTransport";
|
|||
|
||||
import { VerifyLogger } from "./Common";
|
||||
import { TestHttpClient } from "./TestHttpClient";
|
||||
import { PromiseSource, SyncPoint } from "./Utils";
|
||||
import { PromiseSource, registerUnhandledRejectionHandler, SyncPoint } from "./Utils";
|
||||
|
||||
registerUnhandledRejectionHandler();
|
||||
|
||||
describe("LongPollingTransport", () => {
|
||||
it("shuts down polling by aborting in-progress request", async () => {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ import { ServerSentEventsTransport } from "../src/ServerSentEventsTransport";
|
|||
import { VerifyLogger } from "./Common";
|
||||
import { TestEventSource, TestMessageEvent } from "./TestEventSource";
|
||||
import { TestHttpClient } from "./TestHttpClient";
|
||||
import { registerUnhandledRejectionHandler } from "./Utils";
|
||||
|
||||
registerUnhandledRejectionHandler();
|
||||
|
||||
describe("ServerSentEventsTransport", () => {
|
||||
it("does not allow non-text formats", async () => {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { TextMessageFormat } from "../src/TextMessageFormat";
|
||||
import { registerUnhandledRejectionHandler } from "./Utils";
|
||||
|
||||
registerUnhandledRejectionHandler();
|
||||
|
||||
describe("TextMessageFormat", () => {
|
||||
([
|
||||
|
|
|
|||
|
|
@ -3,6 +3,16 @@
|
|||
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;
|
||||
|
||||
export function registerUnhandledRejectionHandler(): void {
|
||||
process.on("unhandledRejection", (error) => {
|
||||
if (error && error.stack) {
|
||||
console.error(error.stack);
|
||||
} else {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function delay(durationInMilliseconds: number): Promise<void> {
|
||||
const source = new PromiseSource<void>();
|
||||
setTimeout(() => source.resolve(), durationInMilliseconds);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ import { WebSocketTransport } from "../src/WebSocketTransport";
|
|||
import { VerifyLogger } from "./Common";
|
||||
import { TestMessageEvent } from "./TestEventSource";
|
||||
import { TestCloseEvent, TestErrorEvent, TestEvent, TestWebSocket } from "./TestWebSocket";
|
||||
import { registerUnhandledRejectionHandler } from "./Utils";
|
||||
|
||||
registerUnhandledRejectionHandler();
|
||||
|
||||
describe("WebSocketTransport", () => {
|
||||
it("sets websocket binarytype to arraybuffer on Binary transferformat", async () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue