Run compiled code in vitest instead of the source typescript
Summary: to avoid troubles with sealcode ts loaders not present in vitest Reviewers: #reviewers Subscribers: jenkins-user Differential Revision: https://hub.sealcode.org/D1431
This commit is contained in:
parent
e1bb10d060
commit
711b52562f
3
.gitignore
vendored
3
.gitignore
vendored
@ -34,4 +34,5 @@ cache/*
|
|||||||
!cache/images/.keepme
|
!cache/images/.keepme
|
||||||
!cache/smartcrop/.keepme
|
!cache/smartcrop/.keepme
|
||||||
uploaded-images/*
|
uploaded-images/*
|
||||||
!uploaded-images/keepme
|
!uploaded-images/keepme
|
||||||
|
uploaded_files
|
@ -8,10 +8,12 @@
|
|||||||
"start": "docker-compose up -d db && node .",
|
"start": "docker-compose up -d db && node .",
|
||||||
"typecheck:back": "npx tsc --noEmit --target es6 --lib es2021,dom -p tsconfig-back.json",
|
"typecheck:back": "npx tsc --noEmit --target es6 --lib es2021,dom -p tsconfig-back.json",
|
||||||
"typecheck:front": "npx tsc --noEmit --target es6 --lib es2015,dom -p tsconfig-front.json",
|
"typecheck:front": "npx tsc --noEmit --target es6 --lib es2015,dom -p tsconfig-front.json",
|
||||||
|
"prebuild": "rm -rf dist/*",
|
||||||
"build": "sealgen build",
|
"build": "sealgen build",
|
||||||
"watch": "multiple-scripts-tmux -p watch",
|
"watch": "multiple-scripts-tmux -p watch",
|
||||||
"reset-db": "docker-compose down && docker-compose up -d",
|
"reset-db": "docker-compose down && docker-compose up -d",
|
||||||
"install-test-deps": "npx playwright install firefox",
|
"install-test-deps": "npx playwright install firefox",
|
||||||
|
"pretest-cmd": "npm run build",
|
||||||
"test-cmd": "vitest --config ./src/back/vitest.config.ts",
|
"test-cmd": "vitest --config ./src/back/vitest.config.ts",
|
||||||
"test-cmd-once": "vitest run --config ./src/back/vitest.config.ts",
|
"test-cmd-once": "vitest run --config ./src/back/vitest.config.ts",
|
||||||
"test": "npm run test-cmd -- --ui",
|
"test": "npm run test-cmd -- --ui",
|
||||||
@ -51,7 +53,6 @@
|
|||||||
"sealious": "^0.18.3",
|
"sealious": "^0.18.3",
|
||||||
"stimulus": "^2.0.0",
|
"stimulus": "^2.0.0",
|
||||||
"tempstream": "^0.3.15",
|
"tempstream": "^0.3.15",
|
||||||
"unplugin-auto-import": "^0.17.5",
|
|
||||||
"vitest": "^1.1.0"
|
"vitest": "^1.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
PORT,
|
PORT,
|
||||||
} from "./config.js";
|
} from "./config.js";
|
||||||
import ADMIN_CREDENTIALS from "./default-admin-credentials.js";
|
import ADMIN_CREDENTIALS from "./default-admin-credentials.js";
|
||||||
import { module_dirname } from "./util.js";
|
import { module_dirname } from "./utils/module_dirname.js";
|
||||||
const locreq = _locreq(module_dirname(import.meta.url));
|
const locreq = _locreq(module_dirname(import.meta.url));
|
||||||
|
|
||||||
declare module "koa" {
|
declare module "koa" {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import _locreq from "locreq";
|
import _locreq from "locreq";
|
||||||
import { module_dirname } from "./util.js";
|
import { module_dirname } from "./utils/module_dirname.js";
|
||||||
|
|
||||||
const locreq = _locreq(module_dirname(import.meta.url));
|
const locreq = _locreq(module_dirname(import.meta.url));
|
||||||
export const SEALIOUS_SANITY = Boolean(process.env.SEALIOUS_SANITY);
|
export const SEALIOUS_SANITY = Boolean(process.env.SEALIOUS_SANITY);
|
||||||
export const PORT = process.env.SEALIOUS_PORT
|
export const PORT = process.env.SEALIOUS_PORT
|
||||||
|
@ -3,7 +3,8 @@ import _locreq from "locreq";
|
|||||||
import TheApp from "./app.js";
|
import TheApp from "./app.js";
|
||||||
import { PORT, SEALIOUS_SANITY } from "./config.js";
|
import { PORT, SEALIOUS_SANITY } from "./config.js";
|
||||||
import { mainRouter } from "./routes/index.js";
|
import { mainRouter } from "./routes/index.js";
|
||||||
import { module_dirname } from "./util.js";
|
import { module_dirname } from "./utils/module_dirname.js";
|
||||||
|
|
||||||
const locreq = _locreq(module_dirname(import.meta.url));
|
const locreq = _locreq(module_dirname(import.meta.url));
|
||||||
|
|
||||||
export const the_app = new TheApp();
|
export const the_app = new TheApp();
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import _locreq from "locreq";
|
import _locreq from "locreq";
|
||||||
import { v4 as uuid } from "uuid";
|
import { v4 as uuid } from "uuid";
|
||||||
|
import { module_dirname } from "../utils/module_dirname.js";
|
||||||
|
|
||||||
const locreq = _locreq(module_dirname(import.meta.url));
|
const locreq = _locreq(module_dirname(import.meta.url));
|
||||||
import { SMTPMailer } from "sealious";
|
import { SMTPMailer } from "sealious";
|
||||||
import { TestUtils } from "sealious";
|
import { TestUtils } from "sealious";
|
||||||
import TheApp from "../app.js";
|
import TheApp from "../app.js";
|
||||||
import { mainRouter } from "../routes/index.js";
|
import { mainRouter } from "../routes/index.js";
|
||||||
import { module_dirname } from "../util.js";
|
|
||||||
import getPort from "get-port";
|
import getPort from "get-port";
|
||||||
import {
|
import {
|
||||||
MAILCATCHER_API_PORT,
|
MAILCATCHER_API_PORT,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import type { BaseContext } from "koa";
|
import type { BaseContext } from "koa";
|
||||||
import qs from "qs";
|
import qs from "qs";
|
||||||
import { dirname } from "node:path";
|
|
||||||
|
|
||||||
export async function sleep(time: number) {
|
export async function sleep(time: number) {
|
||||||
return new Promise((resolve) => setTimeout(resolve, time));
|
return new Promise((resolve) => setTimeout(resolve, time));
|
||||||
@ -21,7 +20,3 @@ export function UrlWithNewParams(
|
|||||||
): string {
|
): string {
|
||||||
return `${ctx.path}?${qs.stringify(query_params)}`;
|
return `${ctx.path}?${qs.stringify(query_params)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function module_dirname(module_url: string): string {
|
|
||||||
return dirname(module_url).replace(/^file:\/\//, "");
|
|
||||||
}
|
|
||||||
|
5
src/back/utils/module_dirname.ts
Normal file
5
src/back/utils/module_dirname.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { dirname } from "node:path";
|
||||||
|
|
||||||
|
export function module_dirname(module_url: string): string {
|
||||||
|
return dirname(module_url).replace(/^file:\/\//, "");
|
||||||
|
}
|
@ -1,8 +1,7 @@
|
|||||||
import { defineConfig } from "vitest/config";
|
import { defineConfig } from "vitest/config";
|
||||||
|
|
||||||
const exclude = ["docker_node_modules", "node_modules", "dist", "lib", "webhint"];
|
// we're testing from the build 'dist' directory
|
||||||
|
const exclude = ["docker_node_modules", "node_modules", "src", "lib", "webhint"];
|
||||||
import AutoImport from "unplugin-auto-import/vite";
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
test: {
|
test: {
|
||||||
@ -14,14 +13,7 @@ export default defineConfig({
|
|||||||
exclude,
|
exclude,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
all: true,
|
all: true,
|
||||||
include: ["src/**", "test?(-*).?(c|m)[jt]s?(x)"],
|
include: ["dist/**"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [
|
|
||||||
AutoImport({
|
|
||||||
include: [/\.tsx?$/],
|
|
||||||
imports: [{ tempstream: [["TempstreamJSX", "React"]] }],
|
|
||||||
dts: false,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user