Merge pull request #13302 from Budibase/tests/shared-core-ci

Tests/shared core ci
This commit is contained in:
Adria Navarro 2024-03-20 12:34:02 +01:00 committed by GitHub
commit a75cdb78b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 28 additions and 50 deletions

@ -1 +1 @@
Subproject commit d68b4f40f85dba3184da8b9d63ef2cd66d4a8ef2 Subproject commit 8baf8586ec078951230c8466d5f13f9b6d5ed055

View File

@ -0,0 +1,10 @@
export default {
preset: "ts-jest",
testEnvironment: "node",
transform: {
"^.+\\.ts?$": "@swc/jest",
},
moduleNameMapper: {
"@budibase/types": "<rootDir>/../types/src",
},
}

View File

@ -11,7 +11,9 @@
"build": "node ../../scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly --paths null", "build": "node ../../scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly --paths null",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"dev": "tsc -p tsconfig.json --watch --preserveWatchOutput", "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput",
"check:types": "tsc -p tsconfig.json --noEmit --paths null" "check:types": "tsc -p tsconfig.json --noEmit --paths null",
"test": "jest",
"test:watch": "yarn test --watchAll"
}, },
"dependencies": { "dependencies": {
"@budibase/types": "0.0.0", "@budibase/types": "0.0.0",
@ -20,29 +22,5 @@
"devDependencies": { "devDependencies": {
"rimraf": "3.0.2", "rimraf": "3.0.2",
"typescript": "5.2.2" "typescript": "5.2.2"
},
"nx": {
"targets": {
"build": {
"dependsOn": [
{
"projects": [
"@budibase/types"
],
"target": "build"
}
]
},
"dev": {
"dependsOn": [
{
"projects": [
"@budibase/types"
],
"target": "build"
}
]
}
}
} }
} }

View File

@ -1,4 +1,3 @@
import { expect, describe, it } from "vitest"
import { cron } from "../helpers" import { cron } from "../helpers"
describe("check valid and invalid crons", () => { describe("check valid and invalid crons", () => {

View File

@ -5,7 +5,6 @@ import {
SearchFilter, SearchFilter,
} from "@budibase/types" } from "@budibase/types"
import { buildLuceneQuery, runLuceneQuery } from "../filters" import { buildLuceneQuery, runLuceneQuery } from "../filters"
import { expect, describe, it, test } from "vitest"
describe("runLuceneQuery", () => { describe("runLuceneQuery", () => {
const docs = [ const docs = [
@ -194,7 +193,7 @@ describe("runLuceneQuery", () => {
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([2, 3]) expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([2, 3])
}) })
test.each([[523, 259], "523,259"])( it.each([[523, 259], "523,259"])(
"should return rows with matches on numeric oneOf filter", "should return rows with matches on numeric oneOf filter",
input => { input => {
const query = buildQuery({ const query = buildQuery({
@ -209,7 +208,7 @@ describe("runLuceneQuery", () => {
} }
) )
test.each([ it.each([
[false, []], [false, []],
[true, [1, 2, 3]], [true, [1, 2, 3]],
])("should return %s if allOr is %s ", (allOr, expectedResult) => { ])("should return %s if allOr is %s ", (allOr, expectedResult) => {

View File

@ -18,13 +18,6 @@
}, },
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
}, },
"include": ["**/*.js", "**/*.ts"], "include": ["src/**/*"],
"exclude": [ "exclude": ["**/*.spec.ts", "**/*.spec.js", "__mocks__", "src/tests"]
"node_modules",
"dist",
"**/*.spec.ts",
"**/*.spec.js",
"__mocks__",
"src/tests"
]
} }

View File

@ -1,9 +1,8 @@
{ {
"extends": "./tsconfig.build.json", "extends": "./tsconfig.build.json",
"compilerOptions": { "compilerOptions": {
"baseUrl": "..", "composite": true,
"rootDir": "src", "types": ["node", "jest"]
"composite": true
}, },
"exclude": ["node_modules", "dist"] "exclude": ["node_modules", "dist"]
} }

View File

@ -3,7 +3,7 @@
"version": "0.0.0", "version": "0.0.0",
"description": "Budibase types", "description": "Budibase types",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "src/index.ts",
"author": "Budibase", "author": "Budibase",
"license": "GPL-3.0", "license": "GPL-3.0",
"scripts": { "scripts": {

View File

@ -7,7 +7,7 @@ import {
ViewTemplateOpts, ViewTemplateOpts,
} from "../" } from "../"
import { Writable } from "stream" import { Writable } from "stream"
import PouchDB from "pouchdb-find" import type PouchDB from "pouchdb-find"
export enum SearchIndex { export enum SearchIndex {
ROWS = "rows", ROWS = "rows",

View File

@ -1,8 +1,6 @@
{ {
"extends": "./tsconfig.build.json", "extends": "./tsconfig.build.json",
"compilerOptions": { "compilerOptions": {
"baseUrl": ".",
"rootDir": "./src",
"composite": true "composite": true
}, },
"exclude": ["node_modules", "dist"] "exclude": ["node_modules", "dist"]

View File

@ -4,10 +4,10 @@ set -e
if [[ -n $CI ]] if [[ -n $CI ]]
then then
# Running in ci, where resources are limited # Running in ci, where resources are limited
echo "jest --coverage --maxWorkers=2 --forceExit --bail $@" echo "jest --coverage --maxWorkers=2 --forceExit --bail $@"
jest --coverage --maxWorkers=2 --forceExit --bail $@ jest --coverage --maxWorkers=2 --forceExit --bail $@
else else
# --maxWorkers performs better in development # --maxWorkers performs better in development
echo "jest --coverage --maxWorkers=2 --forceExit $@" echo "jest --coverage --detectOpenHandles $@"
jest --coverage --maxWorkers=2 --forceExit $@ jest --coverage --detectOpenHandles $@
fi fi

View File

@ -6,6 +6,8 @@ import { TestConfiguration } from "../../../tests"
describe("auth", () => { describe("auth", () => {
const config = new TestConfiguration() const config = new TestConfiguration()
afterAll(config.afterAll)
describe("resetUpdate", () => { describe("resetUpdate", () => {
it("providing a valid code will update the password", async () => { it("providing a valid code will update the password", async () => {
await context.doInTenant(structures.tenant.id(), async () => { await context.doInTenant(structures.tenant.id(), async () => {