From 54642e3b385fbc44f5c28a3b122c29b1ac9a8883 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 29 Sep 2024 03:02:45 -0300 Subject: [PATCH] fix: clear `core.summary` mock --- __tests__/comments.test.ts | 11 +++++++++++ __tests__/parser.test.ts | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/__tests__/comments.test.ts b/__tests__/comments.test.ts index d0bba61..481e576 100644 --- a/__tests__/comments.test.ts +++ b/__tests__/comments.test.ts @@ -20,8 +20,14 @@ describe("deleteOldComments", () => { beforeEach(() => { vi.clearAllMocks(); + Object.defineProperty(core, "summary", { + value: { addRaw: vi.fn(), write: vi.fn() }, + writable: true, + configurable: true + }); }); + it("should delete old comments with watermark", async () => { const comments = [ { id: 1, body: `${watermark} Old comment` }, @@ -84,6 +90,11 @@ describe("commentOnPullRequest", () => { (github.getOctokit as Mock).mockReturnValue(mockOctokit); (core.getInput as Mock).mockReturnValue("token"); github.context.payload = { pull_request: { number: 1 } }; + Object.defineProperty(core, "summary", { + value: { addRaw: vi.fn(), write: vi.fn() }, + writable: true, + configurable: true + }); Object.defineProperty(github.context, "repo", { value: { owner: "owner", repo: "repo" }, writable: true diff --git a/__tests__/parser.test.ts b/__tests__/parser.test.ts index d09ca53..1d529f6 100644 --- a/__tests__/parser.test.ts +++ b/__tests__/parser.test.ts @@ -13,8 +13,14 @@ describe("parseAnalysisOutput", () => { beforeEach(() => { vi.clearAllMocks(); + Object.defineProperty(core, "summary", { + value: { addRaw: vi.fn(), write: vi.fn() }, + writable: true, + configurable: true + }); }); + it("should parse analysis output successfully", () => { (fs.readFileSync as Mock).mockReturnValue(mockFileContent);