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
1
.gitignore
vendored
1
.gitignore
vendored
@ -35,3 +35,4 @@ cache/*
|
||||
!cache/smartcrop/.keepme
|
||||
uploaded-images/*
|
||||
!uploaded-images/keepme
|
||||
uploaded_files
|
@ -8,10 +8,12 @@
|
||||
"start": "docker-compose up -d db && node .",
|
||||
"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",
|
||||
"prebuild": "rm -rf dist/*",
|
||||
"build": "sealgen build",
|
||||
"watch": "multiple-scripts-tmux -p watch",
|
||||
"reset-db": "docker-compose down && docker-compose up -d",
|
||||
"install-test-deps": "npx playwright install firefox",
|
||||
"pretest-cmd": "npm run build",
|
||||
"test-cmd": "vitest --config ./src/back/vitest.config.ts",
|
||||
"test-cmd-once": "vitest run --config ./src/back/vitest.config.ts",
|
||||
"test": "npm run test-cmd -- --ui",
|
||||
@ -51,7 +53,6 @@
|
||||
"sealious": "^0.18.3",
|
||||
"stimulus": "^2.0.0",
|
||||
"tempstream": "^0.3.15",
|
||||
"unplugin-auto-import": "^0.17.5",
|
||||
"vitest": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
PORT,
|
||||
} from "./config.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));
|
||||
|
||||
declare module "koa" {
|
||||
|
@ -1,5 +1,6 @@
|
||||
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));
|
||||
export const SEALIOUS_SANITY = Boolean(process.env.SEALIOUS_SANITY);
|
||||
export const PORT = process.env.SEALIOUS_PORT
|
||||
|
@ -3,7 +3,8 @@ import _locreq from "locreq";
|
||||
import TheApp from "./app.js";
|
||||
import { PORT, SEALIOUS_SANITY } from "./config.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));
|
||||
|
||||
export const the_app = new TheApp();
|
||||
|
@ -1,12 +1,12 @@
|
||||
import _locreq from "locreq";
|
||||
import { v4 as uuid } from "uuid";
|
||||
import { module_dirname } from "../utils/module_dirname.js";
|
||||
|
||||
const locreq = _locreq(module_dirname(import.meta.url));
|
||||
import { SMTPMailer } from "sealious";
|
||||
import { TestUtils } from "sealious";
|
||||
import TheApp from "../app.js";
|
||||
import { mainRouter } from "../routes/index.js";
|
||||
import { module_dirname } from "../util.js";
|
||||
import getPort from "get-port";
|
||||
import {
|
||||
MAILCATCHER_API_PORT,
|
||||
|
@ -1,6 +1,5 @@
|
||||
import type { BaseContext } from "koa";
|
||||
import qs from "qs";
|
||||
import { dirname } from "node:path";
|
||||
|
||||
export async function sleep(time: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, time));
|
||||
@ -21,7 +20,3 @@ export function UrlWithNewParams(
|
||||
): string {
|
||||
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";
|
||||
|
||||
const exclude = ["docker_node_modules", "node_modules", "dist", "lib", "webhint"];
|
||||
|
||||
import AutoImport from "unplugin-auto-import/vite";
|
||||
// we're testing from the build 'dist' directory
|
||||
const exclude = ["docker_node_modules", "node_modules", "src", "lib", "webhint"];
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
@ -14,14 +13,7 @@ export default defineConfig({
|
||||
exclude,
|
||||
enabled: 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