Use a single synapse for all unread tests. (#11489)

Saves about 30 seconds per run.
This commit is contained in:
Andy Balaam 2023-08-30 16:15:47 +01:00 committed by GitHub
parent 6aa86a858f
commit aaea42c626
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,10 +31,26 @@ describe("Read receipts", () => {
let alphaRoomId: string; let alphaRoomId: string;
let bot: MatrixClient | undefined; let bot: MatrixClient | undefined;
beforeEach(() => { before(() => {
// Create 2 rooms: Alpha & Beta. We join the bot to both of them // Note: unusually for the Cypress tests in this repo, we share a single
// Synapse between all the tests in this file.
//
// Stopping and starting Synapse costs about 0.25 seconds per test, so
// for most suites this is worth the cost for the extra assurance that
// each test is independent.
//
// Because there are so many tests in this file, and because sharing a
// Synapse should have no effect (because we create new rooms and users
// for each test), we share it here, saving ~30 seconds per run at time
// of writing.
cy.startHomeserver("default").then((data) => { cy.startHomeserver("default").then((data) => {
homeserver = data; homeserver = data;
});
});
beforeEach(() => {
// Create 2 rooms: Alpha & Beta. We join the bot to both of them
cy.initTestUser(homeserver, userName) cy.initTestUser(homeserver, userName)
.then(() => { .then(() => {
cy.createRoom({ name: roomAlpha }).then((createdRoomId) => { cy.createRoom({ name: roomAlpha }).then((createdRoomId) => {
@ -62,9 +78,8 @@ describe("Read receipts", () => {
cy.findByText(botName + " joined the room").should("exist"); cy.findByText(botName + " joined the room").should("exist");
}); });
}); });
});
afterEach(() => { after(() => {
cy.stopHomeserver(homeserver); cy.stopHomeserver(homeserver);
}); });