Test fixes

This commit is contained in:
Rory Powell 2022-11-16 13:06:30 +00:00
parent 6017f6be47
commit dc70022708
5 changed files with 18 additions and 5 deletions

View File

@ -1,6 +1,9 @@
import env from "../src/environment"
import { mocks } from "./utilities"
// must explicitly enable fetch mock
mocks.fetch.enable()
// mock all dates to 2020-01-01T00:00:00.000Z
// use tk.reset() to use real dates in individual tests
import tk from "timekeeper"

View File

@ -1,4 +1,10 @@
const mockFetch = jest.fn()
jest.mock("node-fetch", () => mockFetch)
export default mockFetch
const enable = () => {
jest.mock("node-fetch", () => mockFetch)
}
export default {
...mockFetch,
enable,
}

View File

@ -1,10 +1,11 @@
import { createMockContext } from "@shopify/jest-koa-mocks"
import { createMockContext, createMockCookies } from "@shopify/jest-koa-mocks"
import { BBContext } from "@budibase/types"
export const newContext = (): BBContext => {
const ctx = createMockContext()
return {
...ctx,
cookies: createMockCookies(),
request: {
...ctx.request,
body: {},

View File

@ -45,11 +45,11 @@ const PUBLIC_ENDPOINTS = [
method: "POST",
},
{
route: "api/system/environment",
route: "/api/system/environment",
method: "GET",
},
{
route: "api/system/status",
route: "/api/system/status",
method: "GET",
},
// TODO: This should be an internal api

View File

@ -14,6 +14,9 @@ env._set("DISABLE_ACCOUNT_PORTAL", false)
import { mocks } from "@budibase/backend-core/tests"
// must explicitly enable fetch mock
mocks.fetch.enable()
// mock all dates to 2020-01-01T00:00:00.000Z
// use tk.reset() to use real dates in individual tests
const tk = require("timekeeper")