1
0
Fork 0
mirror of synced 2024-06-29 11:31:06 +12:00

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")