From 294616b556d12c7b83d7a5f0474f6956d25b5adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dandelion=20Man=C3=A9?= Date: Fri, 27 Jul 2018 15:32:47 -0700 Subject: [PATCH] RepositorySelect tests verify no console errors (#545) We should really do this as a matter of course on all frontend testing. Not sure what the right pattern is for ensuring that. Test plan: Travis --- src/app/credExplorer/RepositorySelect.test.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/app/credExplorer/RepositorySelect.test.js b/src/app/credExplorer/RepositorySelect.test.js index 2430b01..71cae46 100644 --- a/src/app/credExplorer/RepositorySelect.test.js +++ b/src/app/credExplorer/RepositorySelect.test.js @@ -20,6 +20,14 @@ require("../testUtil").configureAphrodite(); describe("app/credExplorer/RepositorySelect", () => { beforeEach(() => { fetch.resetMocks(); + // $ExpectFlowError + console.error = jest.fn(); + // $ExpectFlowError + console.warn = jest.fn(); + }); + afterEach(() => { + expect(console.warn).not.toHaveBeenCalled(); + expect(console.error).not.toHaveBeenCalled(); }); function mockRegistry(registry: RepoRegistry) { @@ -112,7 +120,7 @@ describe("app/credExplorer/RepositorySelect", () => { const result = loadStatus(localStore); expect(fetch).toHaveBeenCalledTimes(1); expect(fetch).toHaveBeenCalledWith(REPO_REGISTRY_API); - expect.assertions(5); + expect.assertions(7); return result.then((status) => { expect(status.type).toBe("VALID"); if (status.type !== "VALID") { @@ -139,14 +147,14 @@ describe("app/credExplorer/RepositorySelect", () => { }); it("returns FAILURE on invalid fetch response", () => { fetch.mockResponseOnce(JSON.stringify(["hello"])); - expect.assertions(1); + expect.assertions(3); return loadStatus(testLocalStore()).then((status) => { expect(status).toEqual({type: "FAILURE"}); }); }); it("returns FAILURE on fetch failure", () => { fetch.mockReject(new Error("some failure")); - expect.assertions(1); + expect.assertions(3); return loadStatus(testLocalStore()).then((status) => { expect(status).toEqual({type: "FAILURE"}); });