Skip to content

Commit d8eba73

Browse files
snitin315alexander-akait
authored andcommitted
test: refactor client's reconnect tests to cleanup properly (#4909)
1 parent d35953d commit d8eba73

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

test/e2e/client-reconnect.test.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,14 @@ describe("client.reconnect option", () => {
4545
waitUntil: "networkidle0",
4646
});
4747

48-
expect(response.status()).toMatchSnapshot("response status");
48+
try {
49+
expect(response.status()).toMatchSnapshot("response status");
50+
} catch (error) {
51+
throw error;
52+
} finally {
53+
await server.stop();
54+
}
4955

50-
await server.stop();
5156
// Can't wait to check for unlimited times so wait only for 5-6 retries
5257
// eslint-disable-next-line no-restricted-properties
5358
await page.waitForTimeout(1000 * Math.pow(2, 5) + Math.random() * 100);
@@ -101,9 +106,14 @@ describe("client.reconnect option", () => {
101106
waitUntil: "networkidle0",
102107
});
103108

104-
expect(response.status()).toMatchSnapshot("response status");
109+
try {
110+
expect(response.status()).toMatchSnapshot("response status");
111+
} catch (error) {
112+
throw error;
113+
} finally {
114+
await server.stop();
115+
}
105116

106-
await server.stop();
107117
// Can't wait to check for unlimited times so wait only for 5-6 retries
108118
// eslint-disable-next-line no-restricted-properties
109119
await page.waitForTimeout(1000 * Math.pow(2, 2) + Math.random() * 100);
@@ -154,9 +164,14 @@ describe("client.reconnect option", () => {
154164
waitUntil: "networkidle0",
155165
});
156166

157-
expect(response.status()).toMatchSnapshot("response status");
167+
try {
168+
expect(response.status()).toMatchSnapshot("response status");
169+
} catch (error) {
170+
throw error;
171+
} finally {
172+
await server.stop();
173+
}
158174

159-
await server.stop();
160175
// eslint-disable-next-line no-restricted-properties
161176
await page.waitForTimeout(1000 * Math.pow(2, 3) + Math.random() * 100);
162177

0 commit comments

Comments
 (0)