Fix flaky timeout test in TS client (#19389)

This commit is contained in:
Brennan 2020-02-27 08:27:48 -08:00 committed by GitHub
parent 5b7672c2ad
commit 2056146c95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -679,7 +679,6 @@ describe("hubConnection", () => {
if (transportType !== HttpTransportType.LongPolling) {
it("terminates if no messages received within timeout interval", async (done) => {
const hubConnection = getConnectionBuilder(transportType).build();
hubConnection.serverTimeoutInMilliseconds = 100;
hubConnection.onclose((error) => {
expect(error).toEqual(new Error("Server timeout elapsed without receiving a message from the server."));
@ -687,6 +686,12 @@ describe("hubConnection", () => {
});
await hubConnection.start();
// set this after start completes to avoid network issues with the handshake taking over 100ms and causing a failure
hubConnection.serverTimeoutInMilliseconds = 1;
// invoke a method with a response to reset the timeout using the new value
await hubConnection.invoke("Echo", "");
});
}