1
0
Fork 0
mirror of synced 2024-06-22 04:10:54 +12:00

Bump jest and ts-jest to be consistent across backend packages to fix CI issue, test config updates

This commit is contained in:
Rory Powell 2022-11-14 22:55:47 +00:00
parent 99cc9ced24
commit 2212305f08
38 changed files with 2337 additions and 2032 deletions

View file

@ -3,7 +3,7 @@ import { Config } from "@jest/types"
const config: Config.InitialOptions = {
preset: "ts-jest",
testEnvironment: "node",
setupFiles: ["./scripts/jestSetup.ts"],
setupFiles: ["./tests/jestSetup.ts"],
collectCoverageFrom: ["src/**/*.{js,ts}"],
coverageReporters: ["lcov", "json", "clover"],
}

View file

@ -67,12 +67,12 @@
"@types/uuid": "8.3.4",
"chance": "1.1.3",
"ioredis-mock": "5.8.0",
"jest": "27.5.1",
"jest": "28.1.1",
"koa": "2.7.0",
"nodemon": "2.0.16",
"pouchdb-adapter-memory": "7.2.2",
"timekeeper": "2.2.0",
"ts-jest": "27.1.5",
"ts-jest": "28.0.4",
"ts-node": "10.8.1",
"tsconfig-paths": "4.0.0",
"typescript": "4.7.3"

View file

@ -1,4 +1,4 @@
require("../../../tests/utilities/TestConfiguration")
require("../../../tests")
const { Writethrough } = require("../writethrough")
const { dangerousGetDB } = require("../../db")
const tk = require("timekeeper")

View file

@ -1,4 +1,4 @@
import "../../../tests/utilities/TestConfiguration"
import "../../../tests"
import * as context from ".."
import { DEFAULT_TENANT_ID } from "../../constants"
import env from "../../environment"

View file

@ -33,7 +33,7 @@ const checkInitialised = () => {
}
}
export async function init(opts?: PouchOptions) {
export function init(opts?: PouchOptions) {
Pouch = pouch.getPouch(opts)
initialised = true
}

View file

@ -1,5 +1,6 @@
import PouchDB from "pouchdb"
import env from "../environment"
import { PouchOptions } from "@budibase/types"
export const getUrlInfo = (url = env.COUCH_DB_URL) => {
let cleanUrl, username, password, host
@ -82,7 +83,7 @@ export const getCouchInfo = () => {
* This should be rarely used outside of the main application config.
* Exposed for exceptional cases such as in-memory views.
*/
export const getPouch = (opts: any = {}) => {
export const getPouch = (opts: PouchOptions = {}) => {
let { url, cookie } = getCouchInfo()
let POUCH_DB_DEFAULTS = {
prefix: url,

View file

@ -1,4 +1,4 @@
require("../../../tests/utilities/TestConfiguration")
require("../../../tests")
const { dangerousGetDB } = require("../")
describe("db", () => {

View file

@ -1,4 +1,4 @@
require("../../../tests/utilities/TestConfiguration")
require("../../../tests")
const getUrlInfo = require("../pouch").getUrlInfo
describe("pouch", () => {

View file

@ -1,4 +1,4 @@
require("../../../tests/utilities/TestConfiguration");
require("../../../tests");
const {
generateAppID,
getDevelopmentAppID,

View file

@ -1,4 +1,4 @@
import "../../../../../tests/utilities/TestConfiguration"
import "../../../../../tests"
import PosthogProcessor from "../PosthogProcessor"
import { Event, IdentityType, Hosting } from "@budibase/types"
const tk = require("timekeeper")

View file

@ -1,4 +1,4 @@
require("../../../../tests/utilities/TestConfiguration")
require("../../../../tests")
const { authenticateThirdParty } = require("../third-party-common")
const { data } = require("./utilities/mock-data")
const { DEFAULT_TENANT_ID } = require("../../../constants")

View file

@ -1,4 +1,4 @@
require("../../../tests/utilities/TestConfiguration")
require("../../../tests")
const { runMigrations, getMigrationsDoc } = require("../index")
const { dangerousGetDB } = require("../../db")
const {

View file

@ -1,5 +1,4 @@
require("../../tests/utilities/TestConfiguration")
const { structures } = require("../../tests/utilities")
const { structures } = require("../../tests")
const utils = require("../utils")
const events = require("../events")
const { doInTenant, DEFAULT_TENANT_ID }= require("../context")

View file

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

View file

@ -1 +0,0 @@
require("./db")

View file

@ -1,6 +0,0 @@
const core = require("../../src/index")
const dbConfig = {
inMemory: true,
allDbs: true,
}
core.init({ db: dbConfig })

View file

@ -0,0 +1,9 @@
import * as db from "../../src/db"
const dbConfig = {
inMemory: true,
}
export const init = () => {
db.init(dbConfig)
}

View file

@ -1,2 +1,5 @@
export * as mocks from "./mocks"
export * as structures from "./structures"
import * as dbConfig from "./db"
dbConfig.init()

File diff suppressed because it is too large Load diff

View file

@ -117,7 +117,7 @@
"start-server-and-test": "^1.12.1",
"svelte": "^3.48.0",
"svelte-jester": "^1.3.2",
"ts-node": "10.8.2",
"ts-node": "10.8.1",
"tsconfig-paths": "4.0.0",
"typescript": "4.7.3",
"vite": "^3.0.8"

View file

@ -5948,10 +5948,10 @@ tr46@~0.0.3:
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=
ts-node@10.8.2:
version "10.8.2"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.8.2.tgz#3185b75228cef116bf82ffe8762594f54b2a23f2"
integrity sha512-LYdGnoGddf1D6v8REPtIH+5iq/gTDuZqv2/UJUU7tKjuEU8xVZorBM+buCGNjj+pGEud+sOoM4CX3/YzINpENA==
ts-node@10.8.1:
version "10.8.1"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.8.1.tgz#ea2bd3459011b52699d7e88daa55a45a1af4f066"
integrity sha512-Wwsnao4DQoJsN034wePSg5nZiw4YKXf56mPIAeD6wVmiv+RytNSWqc2f3fKvcUoV+Yn2+yocD71VOfQHbmVX4g==
dependencies:
"@cspotcode/source-map-support" "^0.8.0"
"@tsconfig/node10" "^1.0.7"

View file

@ -4,7 +4,7 @@ import * as fs from "fs"
const config: Config.InitialOptions = {
preset: "ts-jest",
testEnvironment: "node",
setupFiles: ["./scripts/jestSetup.ts"],
setupFiles: ["./src/tests/jestSetup.ts"],
collectCoverageFrom: [
"src/**/*.{js,ts}",
// The use of coverage with couchdb view functions breaks tests

View file

@ -145,7 +145,7 @@
"eslint": "6.8.0",
"ioredis-mock": "7.2.0",
"is-wsl": "2.2.0",
"jest": "27.5.1",
"jest": "28.1.1",
"jest-openapi": "0.14.2",
"nodemon": "2.0.15",
"openapi-types": "9.3.1",
@ -156,7 +156,7 @@
"supertest": "4.0.2",
"swagger-jsdoc": "6.1.0",
"timekeeper": "2.2.0",
"ts-jest": "27.1.3",
"ts-jest": "28.0.4",
"ts-node": "10.8.1",
"tsconfig-paths": "4.0.0",
"typescript": "4.7.3",

View file

@ -1,5 +1,5 @@
const { tmpdir } = require("os")
const env = require("../src/environment")
import env from "../environment"
env._set("SELF_HOSTED", "1")
env._set("NODE_ENV", "jest")
@ -9,7 +9,7 @@ env._set("BUDIBASE_DIR", tmpdir("budibase-unittests"))
env._set("LOG_LEVEL", "silent")
env._set("PORT", 0)
const { mocks } = require("@budibase/backend-core/tests")
import { mocks } from "@budibase/backend-core/tests"
// mock all dates to 2020-01-01T00:00:00.000Z
// use tk.reset() to use real dates in individual tests

View file

@ -116,7 +116,9 @@ class TestConfiguration {
if (this.server) {
this.server.close()
}
cleanup(this.allApps.map(app => app.appId))
if (this.allApps) {
cleanup(this.allApps.map(app => app.appId))
}
}
// UTILS

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,10 @@
import PouchDB from "pouchdb"
export type PouchOptions = {
inMemory: boolean
replication: boolean
onDisk: boolean
find: boolean
inMemory?: boolean
replication?: boolean
onDisk?: boolean
find?: boolean
}
export enum SortOption {

View file

@ -4,7 +4,7 @@ import * as fs from "fs"
const config: Config.InitialOptions = {
preset: "ts-jest",
testEnvironment: "node",
setupFiles: ["./scripts/jestSetup.ts"],
setupFiles: ["./src/tests/jestSetup.ts"],
collectCoverageFrom: ["src/**/*.{js,ts}"],
coverageReporters: ["lcov", "json", "clover"],
}

View file

@ -79,14 +79,14 @@
"@typescript-eslint/parser": "5.12.0",
"copyfiles": "2.4.1",
"eslint": "6.8.0",
"jest": "27.4.7",
"jest": "28.1.1",
"nodemon": "2.0.15",
"pouchdb-adapter-memory": "7.2.2",
"prettier": "2.3.1",
"rimraf": "3.0.2",
"supertest": "6.2.2",
"timekeeper": "2.2.0",
"ts-jest": "27.1.3",
"ts-jest": "28.0.4",
"ts-node": "10.8.1",
"tsconfig-paths": "4.0.0",
"typescript": "4.7.3",

View file

@ -1,11 +0,0 @@
const core = require("@budibase/backend-core")
const env = require("../environment")
exports.init = () => {
const dbConfig = {}
if (env.isTest() && !env.COUCH_DB_URL) {
dbConfig.inMemory = true
dbConfig.allDbs = true
}
core.init({ db: dbConfig })
}

View file

@ -0,0 +1,10 @@
import core from "@budibase/backend-core"
import env from "../environment"
export const init = () => {
const dbConfig: any = {}
if (env.isTest() && !env.COUCH_DB_URL) {
dbConfig.inMemory = true
}
core.init({ db: dbConfig })
}

View file

@ -13,7 +13,7 @@ import { Scope } from "@sentry/node"
import { Event } from "@sentry/types/dist/event"
import Application from "koa"
import { bootstrap } from "global-agent"
import db from "./db"
import * as db from "./db"
db.init()
const Koa = require("koa")
const destroyable = require("server-destroy")

View file

@ -1,5 +1,5 @@
import "./mocks"
import dbConfig from "../db"
import * as dbConfig from "../db"
dbConfig.init()
import env from "../environment"
import controllers from "./controllers"

View file

@ -1,6 +1,6 @@
import mocks from "./mocks"
import TestConfiguration from "./TestConfiguration"
import structures from "./structures"
import mocks from "./mocks"
import API from "./api"
const pkg = {

View file

@ -1,4 +1,4 @@
const env = require("../src/environment")
import env from "../environment"
env._set("SELF_HOSTED", "1")
env._set("NODE_ENV", "jest")
@ -6,7 +6,7 @@ env._set("JWT_SECRET", "test-jwtsecret")
env._set("LOG_LEVEL", "silent")
env._set("MULTI_TENANCY", true)
const { mocks } = require("@budibase/backend-core/tests")
import { mocks } from "@budibase/backend-core/tests"
// mock all dates to 2020-01-01T00:00:00.000Z
// use tk.reset() to use real dates in individual tests

View file

@ -1,17 +1,17 @@
{
"compilerOptions": {
"target": "es6",
"skipLibCheck": true,
"module": "commonjs",
"lib": ["es2020"],
"allowJs": true,
"outDir": "dist",
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"incremental": true,
"types": [ "node", "jest" ],
"outDir": "dist",
"skipLibCheck": true
"types": [ "node", "jest"],
},
"include": [
"src/**/*"
@ -20,7 +20,7 @@
"node_modules",
"dist",
"src/tests",
"**/*.spec.ts",
"**/*.spec.js"
"**/*.spec.js",
"**/*.spec.ts"
]
}

File diff suppressed because it is too large Load diff

View file

@ -41,7 +41,7 @@
"@types/node-fetch": "2.6.2",
"chance": "1.1.8",
"env-cmd": "^10.1.0",
"jest": "28.0.2",
"jest": "28.1.1",
"prettier": "2.7.1",
"start-server-and-test": "1.14.0",
"timekeeper": "2.2.0",