mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 00:18:19 +01:00
fix: 💚 Run every test file separately instead of using the global bun test command
This commit is contained in:
parent
de8b8e2cc0
commit
c7ec678a3e
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
|
|
@ -48,4 +48,4 @@ jobs:
|
|||
|
||||
- name: Run tests
|
||||
run: |
|
||||
bun test
|
||||
bun run test
|
||||
|
|
|
|||
|
|
@ -83,9 +83,11 @@ If your port number is lower than 1024, you may need to run the command as root.
|
|||
|
||||
To run the tests, run:
|
||||
```sh
|
||||
bun test
|
||||
bun run test
|
||||
```
|
||||
|
||||
The `bun test` command will cause errors due to Bun bugs ([oven-sh/bun#7823](https://github.com/oven-sh/bun/issues/7823)). Use the `test` script instead.
|
||||
|
||||
The tests are located all around the codebase (filename `*.test.ts`) and follow a Jest-like syntax. The server should be shut down before running the tests.
|
||||
|
||||
## Code style
|
||||
|
|
|
|||
1
app.ts
1
app.ts
|
|
@ -220,7 +220,6 @@ export const appFactory = async () => {
|
|||
});
|
||||
|
||||
app.onError((error, c) => {
|
||||
console.error(error);
|
||||
serverLogger.error`${error}`;
|
||||
sentry?.captureException(error);
|
||||
return c.json(
|
||||
|
|
|
|||
3
index.ts
3
index.ts
|
|
@ -1,12 +1,9 @@
|
|||
import cluster from "node:cluster";
|
||||
import { configureLoggers } from "@/loggers";
|
||||
import { sentry } from "@/sentry";
|
||||
import { createServer } from "@/server";
|
||||
import { appFactory } from "~/app";
|
||||
import { config } from "~/packages/config-manager/index";
|
||||
|
||||
await configureLoggers();
|
||||
|
||||
if (cluster.isPrimary) {
|
||||
for (let i = 0; i < Number(process.env.NUM_CPUS ?? 1); i++) {
|
||||
cluster.fork();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { config } from "~/packages/config-manager";
|
|||
|
||||
export const logger = createMiddleware(async (context, next) => {
|
||||
if (config.logging.log_requests) {
|
||||
const logger = getLogger("server");
|
||||
const serverLogger = getLogger("server");
|
||||
const body = await context.req.raw.clone().text();
|
||||
|
||||
const urlAndMethod = `${chalk.green(context.req.method)} ${chalk.blue(context.req.url)}`;
|
||||
|
|
@ -26,9 +26,9 @@ export const logger = createMiddleware(async (context, next) => {
|
|||
const bodyLog = `${chalk.bold("Body")}: ${chalk.gray(body)}`;
|
||||
|
||||
if (config.logging.log_requests_verbose) {
|
||||
logger.debug`${urlAndMethod}\n${hash}\n${headers}\n${bodyLog}`;
|
||||
serverLogger.debug`${urlAndMethod}\n${hash}\n${headers}\n${bodyLog}`;
|
||||
} else {
|
||||
logger.debug`${urlAndMethod}`;
|
||||
serverLogger.debug`${urlAndMethod}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@
|
|||
"cli": "bun run cli/index.ts",
|
||||
"prune": "ts-prune | grep -v server/ | grep -v dist/ | grep -v '(used in module)'",
|
||||
"schema:generate": "bun run packages/config-manager/json-schema.ts > config/config.schema.json && bun run packages/plugin-kit/json-schema.ts > packages/plugin-kit/manifest.schema.json",
|
||||
"check": "bunx tsc -p ."
|
||||
"check": "bunx tsc -p .",
|
||||
"test": "find . -name \"*.test.ts\" -not -path \"./node_modules/*\" | xargs -I {} sh -c 'bun test {} || exit 255'"
|
||||
},
|
||||
"trustedDependencies": [
|
||||
"@biomejs/biome",
|
||||
|
|
|
|||
Loading…
Reference in a new issue