Skip to content

Commit b9e968d

Browse files
snitin315alexander-akait
authored andcommitted
test: refactor stats tests to cleanup properly (#4918)
1 parent e5ed5ed commit b9e968d

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

test/e2e/stats.test.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,22 +120,26 @@ describe("stats", () => {
120120

121121
const { page, browser } = await runBrowser();
122122

123-
const consoleMessages = [];
123+
try {
124+
const consoleMessages = [];
124125

125-
page.on("console", (message) => {
126-
consoleMessages.push(message);
127-
});
126+
page.on("console", (message) => {
127+
consoleMessages.push(message);
128+
});
128129

129-
await page.goto(`http://localhost:${port}/`, {
130-
waitUntil: "networkidle0",
131-
});
130+
await page.goto(`http://localhost:${port}/`, {
131+
waitUntil: "networkidle0",
132+
});
132133

133-
expect(
134-
consoleMessages.map((message) => message.text())
135-
).toMatchSnapshot();
136-
137-
await browser.close();
138-
await server.stop();
134+
expect(
135+
consoleMessages.map((message) => message.text())
136+
).toMatchSnapshot();
137+
} catch (error) {
138+
throw error;
139+
} finally {
140+
await browser.close();
141+
await server.stop();
142+
}
139143
});
140144
});
141145
});

0 commit comments

Comments
 (0)