Bump jest and ts-jest to be consistent across backend packages to fix CI issue, test config updates
This commit is contained in:
parent
99cc9ced24
commit
2212305f08
|
@ -3,7 +3,7 @@ import { Config } from "@jest/types"
|
||||||
const config: Config.InitialOptions = {
|
const config: Config.InitialOptions = {
|
||||||
preset: "ts-jest",
|
preset: "ts-jest",
|
||||||
testEnvironment: "node",
|
testEnvironment: "node",
|
||||||
setupFiles: ["./scripts/jestSetup.ts"],
|
setupFiles: ["./tests/jestSetup.ts"],
|
||||||
collectCoverageFrom: ["src/**/*.{js,ts}"],
|
collectCoverageFrom: ["src/**/*.{js,ts}"],
|
||||||
coverageReporters: ["lcov", "json", "clover"],
|
coverageReporters: ["lcov", "json", "clover"],
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,12 +67,12 @@
|
||||||
"@types/uuid": "8.3.4",
|
"@types/uuid": "8.3.4",
|
||||||
"chance": "1.1.3",
|
"chance": "1.1.3",
|
||||||
"ioredis-mock": "5.8.0",
|
"ioredis-mock": "5.8.0",
|
||||||
"jest": "27.5.1",
|
"jest": "28.1.1",
|
||||||
"koa": "2.7.0",
|
"koa": "2.7.0",
|
||||||
"nodemon": "2.0.16",
|
"nodemon": "2.0.16",
|
||||||
"pouchdb-adapter-memory": "7.2.2",
|
"pouchdb-adapter-memory": "7.2.2",
|
||||||
"timekeeper": "2.2.0",
|
"timekeeper": "2.2.0",
|
||||||
"ts-jest": "27.1.5",
|
"ts-jest": "28.0.4",
|
||||||
"ts-node": "10.8.1",
|
"ts-node": "10.8.1",
|
||||||
"tsconfig-paths": "4.0.0",
|
"tsconfig-paths": "4.0.0",
|
||||||
"typescript": "4.7.3"
|
"typescript": "4.7.3"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require("../../../tests/utilities/TestConfiguration")
|
require("../../../tests")
|
||||||
const { Writethrough } = require("../writethrough")
|
const { Writethrough } = require("../writethrough")
|
||||||
const { dangerousGetDB } = require("../../db")
|
const { dangerousGetDB } = require("../../db")
|
||||||
const tk = require("timekeeper")
|
const tk = require("timekeeper")
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import "../../../tests/utilities/TestConfiguration"
|
import "../../../tests"
|
||||||
import * as context from ".."
|
import * as context from ".."
|
||||||
import { DEFAULT_TENANT_ID } from "../../constants"
|
import { DEFAULT_TENANT_ID } from "../../constants"
|
||||||
import env from "../../environment"
|
import env from "../../environment"
|
||||||
|
|
|
@ -33,7 +33,7 @@ const checkInitialised = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function init(opts?: PouchOptions) {
|
export function init(opts?: PouchOptions) {
|
||||||
Pouch = pouch.getPouch(opts)
|
Pouch = pouch.getPouch(opts)
|
||||||
initialised = true
|
initialised = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import PouchDB from "pouchdb"
|
import PouchDB from "pouchdb"
|
||||||
import env from "../environment"
|
import env from "../environment"
|
||||||
|
import { PouchOptions } from "@budibase/types"
|
||||||
|
|
||||||
export const getUrlInfo = (url = env.COUCH_DB_URL) => {
|
export const getUrlInfo = (url = env.COUCH_DB_URL) => {
|
||||||
let cleanUrl, username, password, host
|
let cleanUrl, username, password, host
|
||||||
|
@ -82,7 +83,7 @@ export const getCouchInfo = () => {
|
||||||
* This should be rarely used outside of the main application config.
|
* This should be rarely used outside of the main application config.
|
||||||
* Exposed for exceptional cases such as in-memory views.
|
* Exposed for exceptional cases such as in-memory views.
|
||||||
*/
|
*/
|
||||||
export const getPouch = (opts: any = {}) => {
|
export const getPouch = (opts: PouchOptions = {}) => {
|
||||||
let { url, cookie } = getCouchInfo()
|
let { url, cookie } = getCouchInfo()
|
||||||
let POUCH_DB_DEFAULTS = {
|
let POUCH_DB_DEFAULTS = {
|
||||||
prefix: url,
|
prefix: url,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require("../../../tests/utilities/TestConfiguration")
|
require("../../../tests")
|
||||||
const { dangerousGetDB } = require("../")
|
const { dangerousGetDB } = require("../")
|
||||||
|
|
||||||
describe("db", () => {
|
describe("db", () => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require("../../../tests/utilities/TestConfiguration")
|
require("../../../tests")
|
||||||
const getUrlInfo = require("../pouch").getUrlInfo
|
const getUrlInfo = require("../pouch").getUrlInfo
|
||||||
|
|
||||||
describe("pouch", () => {
|
describe("pouch", () => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require("../../../tests/utilities/TestConfiguration");
|
require("../../../tests");
|
||||||
const {
|
const {
|
||||||
generateAppID,
|
generateAppID,
|
||||||
getDevelopmentAppID,
|
getDevelopmentAppID,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import "../../../../../tests/utilities/TestConfiguration"
|
import "../../../../../tests"
|
||||||
import PosthogProcessor from "../PosthogProcessor"
|
import PosthogProcessor from "../PosthogProcessor"
|
||||||
import { Event, IdentityType, Hosting } from "@budibase/types"
|
import { Event, IdentityType, Hosting } from "@budibase/types"
|
||||||
const tk = require("timekeeper")
|
const tk = require("timekeeper")
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require("../../../../tests/utilities/TestConfiguration")
|
require("../../../../tests")
|
||||||
const { authenticateThirdParty } = require("../third-party-common")
|
const { authenticateThirdParty } = require("../third-party-common")
|
||||||
const { data } = require("./utilities/mock-data")
|
const { data } = require("./utilities/mock-data")
|
||||||
const { DEFAULT_TENANT_ID } = require("../../../constants")
|
const { DEFAULT_TENANT_ID } = require("../../../constants")
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require("../../../tests/utilities/TestConfiguration")
|
require("../../../tests")
|
||||||
const { runMigrations, getMigrationsDoc } = require("../index")
|
const { runMigrations, getMigrationsDoc } = require("../index")
|
||||||
const { dangerousGetDB } = require("../../db")
|
const { dangerousGetDB } = require("../../db")
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
require("../../tests/utilities/TestConfiguration")
|
const { structures } = require("../../tests")
|
||||||
const { structures } = require("../../tests/utilities")
|
|
||||||
const utils = require("../utils")
|
const utils = require("../utils")
|
||||||
const events = require("../events")
|
const events = require("../events")
|
||||||
const { doInTenant, DEFAULT_TENANT_ID }= require("../context")
|
const { doInTenant, DEFAULT_TENANT_ID }= require("../context")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import env from "../src/environment"
|
import env from "../src/environment"
|
||||||
import { mocks } from "../tests/utilities"
|
import { mocks } from "./utilities"
|
||||||
|
|
||||||
// mock all dates to 2020-01-01T00:00:00.000Z
|
// mock all dates to 2020-01-01T00:00:00.000Z
|
||||||
// use tk.reset() to use real dates in individual tests
|
// use tk.reset() to use real dates in individual tests
|
|
@ -1 +0,0 @@
|
||||||
require("./db")
|
|
|
@ -1,6 +0,0 @@
|
||||||
const core = require("../../src/index")
|
|
||||||
const dbConfig = {
|
|
||||||
inMemory: true,
|
|
||||||
allDbs: true,
|
|
||||||
}
|
|
||||||
core.init({ db: dbConfig })
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
import * as db from "../../src/db"
|
||||||
|
|
||||||
|
const dbConfig = {
|
||||||
|
inMemory: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
export const init = () => {
|
||||||
|
db.init(dbConfig)
|
||||||
|
}
|
|
@ -1,2 +1,5 @@
|
||||||
export * as mocks from "./mocks"
|
export * as mocks from "./mocks"
|
||||||
export * as structures from "./structures"
|
export * as structures from "./structures"
|
||||||
|
|
||||||
|
import * as dbConfig from "./db"
|
||||||
|
dbConfig.init()
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -117,7 +117,7 @@
|
||||||
"start-server-and-test": "^1.12.1",
|
"start-server-and-test": "^1.12.1",
|
||||||
"svelte": "^3.48.0",
|
"svelte": "^3.48.0",
|
||||||
"svelte-jester": "^1.3.2",
|
"svelte-jester": "^1.3.2",
|
||||||
"ts-node": "10.8.2",
|
"ts-node": "10.8.1",
|
||||||
"tsconfig-paths": "4.0.0",
|
"tsconfig-paths": "4.0.0",
|
||||||
"typescript": "4.7.3",
|
"typescript": "4.7.3",
|
||||||
"vite": "^3.0.8"
|
"vite": "^3.0.8"
|
||||||
|
|
|
@ -5948,10 +5948,10 @@ tr46@~0.0.3:
|
||||||
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
|
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
|
||||||
integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=
|
integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=
|
||||||
|
|
||||||
ts-node@10.8.2:
|
ts-node@10.8.1:
|
||||||
version "10.8.2"
|
version "10.8.1"
|
||||||
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.8.2.tgz#3185b75228cef116bf82ffe8762594f54b2a23f2"
|
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.8.1.tgz#ea2bd3459011b52699d7e88daa55a45a1af4f066"
|
||||||
integrity sha512-LYdGnoGddf1D6v8REPtIH+5iq/gTDuZqv2/UJUU7tKjuEU8xVZorBM+buCGNjj+pGEud+sOoM4CX3/YzINpENA==
|
integrity sha512-Wwsnao4DQoJsN034wePSg5nZiw4YKXf56mPIAeD6wVmiv+RytNSWqc2f3fKvcUoV+Yn2+yocD71VOfQHbmVX4g==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@cspotcode/source-map-support" "^0.8.0"
|
"@cspotcode/source-map-support" "^0.8.0"
|
||||||
"@tsconfig/node10" "^1.0.7"
|
"@tsconfig/node10" "^1.0.7"
|
||||||
|
|
|
@ -4,7 +4,7 @@ import * as fs from "fs"
|
||||||
const config: Config.InitialOptions = {
|
const config: Config.InitialOptions = {
|
||||||
preset: "ts-jest",
|
preset: "ts-jest",
|
||||||
testEnvironment: "node",
|
testEnvironment: "node",
|
||||||
setupFiles: ["./scripts/jestSetup.ts"],
|
setupFiles: ["./src/tests/jestSetup.ts"],
|
||||||
collectCoverageFrom: [
|
collectCoverageFrom: [
|
||||||
"src/**/*.{js,ts}",
|
"src/**/*.{js,ts}",
|
||||||
// The use of coverage with couchdb view functions breaks tests
|
// The use of coverage with couchdb view functions breaks tests
|
||||||
|
|
|
@ -145,7 +145,7 @@
|
||||||
"eslint": "6.8.0",
|
"eslint": "6.8.0",
|
||||||
"ioredis-mock": "7.2.0",
|
"ioredis-mock": "7.2.0",
|
||||||
"is-wsl": "2.2.0",
|
"is-wsl": "2.2.0",
|
||||||
"jest": "27.5.1",
|
"jest": "28.1.1",
|
||||||
"jest-openapi": "0.14.2",
|
"jest-openapi": "0.14.2",
|
||||||
"nodemon": "2.0.15",
|
"nodemon": "2.0.15",
|
||||||
"openapi-types": "9.3.1",
|
"openapi-types": "9.3.1",
|
||||||
|
@ -156,7 +156,7 @@
|
||||||
"supertest": "4.0.2",
|
"supertest": "4.0.2",
|
||||||
"swagger-jsdoc": "6.1.0",
|
"swagger-jsdoc": "6.1.0",
|
||||||
"timekeeper": "2.2.0",
|
"timekeeper": "2.2.0",
|
||||||
"ts-jest": "27.1.3",
|
"ts-jest": "28.0.4",
|
||||||
"ts-node": "10.8.1",
|
"ts-node": "10.8.1",
|
||||||
"tsconfig-paths": "4.0.0",
|
"tsconfig-paths": "4.0.0",
|
||||||
"typescript": "4.7.3",
|
"typescript": "4.7.3",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { tmpdir } = require("os")
|
const { tmpdir } = require("os")
|
||||||
const env = require("../src/environment")
|
import env from "../environment"
|
||||||
|
|
||||||
env._set("SELF_HOSTED", "1")
|
env._set("SELF_HOSTED", "1")
|
||||||
env._set("NODE_ENV", "jest")
|
env._set("NODE_ENV", "jest")
|
||||||
|
@ -9,7 +9,7 @@ env._set("BUDIBASE_DIR", tmpdir("budibase-unittests"))
|
||||||
env._set("LOG_LEVEL", "silent")
|
env._set("LOG_LEVEL", "silent")
|
||||||
env._set("PORT", 0)
|
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
|
// mock all dates to 2020-01-01T00:00:00.000Z
|
||||||
// use tk.reset() to use real dates in individual tests
|
// use tk.reset() to use real dates in individual tests
|
|
@ -116,8 +116,10 @@ class TestConfiguration {
|
||||||
if (this.server) {
|
if (this.server) {
|
||||||
this.server.close()
|
this.server.close()
|
||||||
}
|
}
|
||||||
|
if (this.allApps) {
|
||||||
cleanup(this.allApps.map(app => app.appId))
|
cleanup(this.allApps.map(app => app.appId))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// UTILS
|
// UTILS
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +1,10 @@
|
||||||
import PouchDB from "pouchdb"
|
import PouchDB from "pouchdb"
|
||||||
|
|
||||||
export type PouchOptions = {
|
export type PouchOptions = {
|
||||||
inMemory: boolean
|
inMemory?: boolean
|
||||||
replication: boolean
|
replication?: boolean
|
||||||
onDisk: boolean
|
onDisk?: boolean
|
||||||
find: boolean
|
find?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SortOption {
|
export enum SortOption {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import * as fs from "fs"
|
||||||
const config: Config.InitialOptions = {
|
const config: Config.InitialOptions = {
|
||||||
preset: "ts-jest",
|
preset: "ts-jest",
|
||||||
testEnvironment: "node",
|
testEnvironment: "node",
|
||||||
setupFiles: ["./scripts/jestSetup.ts"],
|
setupFiles: ["./src/tests/jestSetup.ts"],
|
||||||
collectCoverageFrom: ["src/**/*.{js,ts}"],
|
collectCoverageFrom: ["src/**/*.{js,ts}"],
|
||||||
coverageReporters: ["lcov", "json", "clover"],
|
coverageReporters: ["lcov", "json", "clover"],
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,14 +79,14 @@
|
||||||
"@typescript-eslint/parser": "5.12.0",
|
"@typescript-eslint/parser": "5.12.0",
|
||||||
"copyfiles": "2.4.1",
|
"copyfiles": "2.4.1",
|
||||||
"eslint": "6.8.0",
|
"eslint": "6.8.0",
|
||||||
"jest": "27.4.7",
|
"jest": "28.1.1",
|
||||||
"nodemon": "2.0.15",
|
"nodemon": "2.0.15",
|
||||||
"pouchdb-adapter-memory": "7.2.2",
|
"pouchdb-adapter-memory": "7.2.2",
|
||||||
"prettier": "2.3.1",
|
"prettier": "2.3.1",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
"supertest": "6.2.2",
|
"supertest": "6.2.2",
|
||||||
"timekeeper": "2.2.0",
|
"timekeeper": "2.2.0",
|
||||||
"ts-jest": "27.1.3",
|
"ts-jest": "28.0.4",
|
||||||
"ts-node": "10.8.1",
|
"ts-node": "10.8.1",
|
||||||
"tsconfig-paths": "4.0.0",
|
"tsconfig-paths": "4.0.0",
|
||||||
"typescript": "4.7.3",
|
"typescript": "4.7.3",
|
||||||
|
|
|
@ -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 })
|
|
||||||
}
|
|
|
@ -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 })
|
||||||
|
}
|
|
@ -13,7 +13,7 @@ import { Scope } from "@sentry/node"
|
||||||
import { Event } from "@sentry/types/dist/event"
|
import { Event } from "@sentry/types/dist/event"
|
||||||
import Application from "koa"
|
import Application from "koa"
|
||||||
import { bootstrap } from "global-agent"
|
import { bootstrap } from "global-agent"
|
||||||
import db from "./db"
|
import * as db from "./db"
|
||||||
db.init()
|
db.init()
|
||||||
const Koa = require("koa")
|
const Koa = require("koa")
|
||||||
const destroyable = require("server-destroy")
|
const destroyable = require("server-destroy")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import "./mocks"
|
import "./mocks"
|
||||||
import dbConfig from "../db"
|
import * as dbConfig from "../db"
|
||||||
dbConfig.init()
|
dbConfig.init()
|
||||||
import env from "../environment"
|
import env from "../environment"
|
||||||
import controllers from "./controllers"
|
import controllers from "./controllers"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
import mocks from "./mocks"
|
||||||
import TestConfiguration from "./TestConfiguration"
|
import TestConfiguration from "./TestConfiguration"
|
||||||
import structures from "./structures"
|
import structures from "./structures"
|
||||||
import mocks from "./mocks"
|
|
||||||
import API from "./api"
|
import API from "./api"
|
||||||
|
|
||||||
const pkg = {
|
const pkg = {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const env = require("../src/environment")
|
import env from "../environment"
|
||||||
|
|
||||||
env._set("SELF_HOSTED", "1")
|
env._set("SELF_HOSTED", "1")
|
||||||
env._set("NODE_ENV", "jest")
|
env._set("NODE_ENV", "jest")
|
||||||
|
@ -6,7 +6,7 @@ env._set("JWT_SECRET", "test-jwtsecret")
|
||||||
env._set("LOG_LEVEL", "silent")
|
env._set("LOG_LEVEL", "silent")
|
||||||
env._set("MULTI_TENANCY", true)
|
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
|
// mock all dates to 2020-01-01T00:00:00.000Z
|
||||||
// use tk.reset() to use real dates in individual tests
|
// use tk.reset() to use real dates in individual tests
|
|
@ -1,17 +1,17 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
|
"skipLibCheck": true,
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"lib": ["es2020"],
|
"lib": ["es2020"],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
|
"outDir": "dist",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"types": [ "node", "jest"],
|
"types": [ "node", "jest"],
|
||||||
"outDir": "dist",
|
|
||||||
"skipLibCheck": true
|
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*"
|
"src/**/*"
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"dist",
|
"dist",
|
||||||
"src/tests",
|
"src/tests",
|
||||||
"**/*.spec.ts",
|
"**/*.spec.js",
|
||||||
"**/*.spec.js"
|
"**/*.spec.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -41,7 +41,7 @@
|
||||||
"@types/node-fetch": "2.6.2",
|
"@types/node-fetch": "2.6.2",
|
||||||
"chance": "1.1.8",
|
"chance": "1.1.8",
|
||||||
"env-cmd": "^10.1.0",
|
"env-cmd": "^10.1.0",
|
||||||
"jest": "28.0.2",
|
"jest": "28.1.1",
|
||||||
"prettier": "2.7.1",
|
"prettier": "2.7.1",
|
||||||
"start-server-and-test": "1.14.0",
|
"start-server-and-test": "1.14.0",
|
||||||
"timekeeper": "2.2.0",
|
"timekeeper": "2.2.0",
|
||||||
|
|
Loading…
Reference in New Issue