diff --git a/packages/server/src/api/routes/tests/table.spec.ts b/packages/server/src/api/routes/tests/table.spec.ts index b5d0107981..efa9845fcb 100644 --- a/packages/server/src/api/routes/tests/table.spec.ts +++ b/packages/server/src/api/routes/tests/table.spec.ts @@ -348,6 +348,7 @@ describe("/tables", () => { describe("fetch", () => { let testTable: Table + const enrichViewSchemasMock = jest.spyOn(sdk.tables, "enrichViewSchemas") beforeEach(async () => { testTable = await config.createTable(testTable) @@ -357,6 +358,10 @@ describe("/tables", () => { delete testTable._rev }) + afterAll(() => { + enrichViewSchemasMock.mockRestore() + }) + it("returns all the tables for that instance in the response body", async () => { const res = await request .get(`/api/tables`) @@ -405,7 +410,7 @@ describe("/tables", () => { it("should enrich the view schemas for viewsV2", async () => { const tableId = config.table!._id! - jest.spyOn(sdk.tables, "enrichViewSchemas").mockImplementation(t => ({ + enrichViewSchemasMock.mockImplementation(t => ({ ...t, views: { view1: { @@ -413,7 +418,7 @@ describe("/tables", () => { name: "view1", schema: {}, id: "new_view_id", - tableId, + tableId: t._id!, }, }, })) @@ -480,11 +485,7 @@ describe("/tables", () => { let testTable: Table beforeEach(async () => { - testTable = await config.createTable(testTable) - }) - - afterEach(() => { - delete testTable._rev + testTable = await config.createTable() }) it("returns a success response when a table is deleted.", async () => {