From ed1462952eaf63e44842b1e87798a8ffb647fcfb Mon Sep 17 00:00:00 2001 From: Javier Bullrich Date: Wed, 29 Nov 2023 12:51:14 +0100 Subject: [PATCH] extended test timeout It seems there are more fellows so the test takes more time. I also moved the timeout to the fellows tests so it doesn't extend the timeout in other tests that work properly with the shorter one --- jest.config.js | 1 - src/test/fellows.test.ts | 78 ++++++++++++++++++++++++---------------- 2 files changed, 48 insertions(+), 31 deletions(-) diff --git a/jest.config.js b/jest.config.js index 70446f9..d9102de 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,6 +2,5 @@ module.exports = { preset: "ts-jest", testEnvironment: "node", - testTimeout: 8_000, testMatch: [__dirname + "/src/**/test/**/*.test.ts"], }; diff --git a/src/test/fellows.test.ts b/src/test/fellows.test.ts index eba8038..bfe275e 100644 --- a/src/test/fellows.test.ts +++ b/src/test/fellows.test.ts @@ -4,6 +4,8 @@ import { mock, mockClear, MockProxy } from "jest-mock-extended"; import { ActionLogger, TeamApi } from "../github/types"; import { PolkadotFellows } from "../polkadot/fellows"; +const timeout = 10_000; + describe("CAPI test", () => { let fellows: TeamApi; let logger: MockProxy; @@ -13,20 +15,28 @@ describe("CAPI test", () => { fellows = new PolkadotFellows(logger); }); - test("Should fetch fellows", async () => { - const members = await fellows.getTeamMembers("2"); - expect(members.length).toBeGreaterThan(0); - }); + test( + "Should fetch fellows", + async () => { + const members = await fellows.getTeamMembers("2"); + expect(members.length).toBeGreaterThan(0); + }, + timeout, + ); - test("Should cache fellows", async () => { - const members = await fellows.getTeamMembers("2"); - expect(members.length).toBeGreaterThan(0); - expect(logger.debug).toHaveBeenCalledWith("Connecting to collective parachain"); - mockClear(logger); - const members2 = await fellows.getTeamMembers("2"); - expect(members2.length).toBeGreaterThan(0); - expect(logger.debug).not.toHaveBeenCalledWith("Connecting to collective parachain"); - }); + test( + "Should cache fellows", + async () => { + const members = await fellows.getTeamMembers("2"); + expect(members.length).toBeGreaterThan(0); + expect(logger.debug).toHaveBeenCalledWith("Connecting to collective parachain"); + mockClear(logger); + const members2 = await fellows.getTeamMembers("2"); + expect(members2.length).toBeGreaterThan(0); + expect(logger.debug).not.toHaveBeenCalledWith("Connecting to collective parachain"); + }, + timeout, + ); describe("Fetch by rank", () => { beforeEach(() => { @@ -39,27 +49,35 @@ describe("CAPI test", () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any (fellows as any).fellowsCache = fellowsMap; }); - test("should return fellows of a give rank", async () => { - const rank1 = await fellows.getTeamMembers("1"); - expect(rank1).toEqual(["user-1", "user-2", "user-3", "user-4", "user-5"]); + test( + "should return fellows of a give rank", + async () => { + const rank1 = await fellows.getTeamMembers("1"); + expect(rank1).toEqual(["user-1", "user-2", "user-3", "user-4", "user-5"]); - const rank2 = await fellows.getTeamMembers("2"); - expect(rank2).toEqual(["user-2", "user-3", "user-4", "user-5"]); + const rank2 = await fellows.getTeamMembers("2"); + expect(rank2).toEqual(["user-2", "user-3", "user-4", "user-5"]); - const rank3 = await fellows.getTeamMembers("3"); - expect(rank3).toEqual(["user-3", "user-4", "user-5"]); + const rank3 = await fellows.getTeamMembers("3"); + expect(rank3).toEqual(["user-3", "user-4", "user-5"]); - const rank4 = await fellows.getTeamMembers("4"); - expect(rank4).toEqual(["user-4", "user-5"]); + const rank4 = await fellows.getTeamMembers("4"); + expect(rank4).toEqual(["user-4", "user-5"]); - const rank5 = await fellows.getTeamMembers("5"); - expect(rank5).toEqual(["user-5"]); - }); + const rank5 = await fellows.getTeamMembers("5"); + expect(rank5).toEqual(["user-5"]); + }, + timeout, + ); - test("should throw if there are no fellows available", async () => { - await expect(fellows.getTeamMembers("6")).rejects.toThrowError( - "Found no members of rank 6 or higher. Please see debug logs", - ); - }); + test( + "should throw if there are no fellows available", + async () => { + await expect(fellows.getTeamMembers("6")).rejects.toThrowError( + "Found no members of rank 6 or higher. Please see debug logs", + ); + }, + timeout, + ); }); });