test: add vitest

* feature(root): add vitest and some basic tests

* fix(test): after rebase + added referrars test and more sites

* fix(test): test broken after rebase

* fix(test): provide db url to make prisma happy

* fix tests
This commit is contained in:
Carl-Gerhard Lindesvärd
2025-06-06 19:14:18 +02:00
committed by GitHub
parent 09c83ddeb4
commit 5445d6309e
23 changed files with 1131 additions and 3133 deletions

27
vitest.shared.ts Normal file
View File

@@ -0,0 +1,27 @@
import * as path from 'node:path';
import { defineConfig } from 'vitest/config';
export const getSharedVitestConfig = ({
__dirname: dirname,
}: { __dirname: string }) => {
return defineConfig({
resolve: {
alias: {
'@': path.resolve(dirname, 'src'),
},
},
test: {
env: {
// Not used, just so prisma is happy
DATABASE_URL: 'postgresql://u:p@127.0.0.1:5432/db',
},
include: ['**/*.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
browser: {
name: 'chromium',
provider: 'playwright',
headless: true,
},
fakeTimers: { toFake: undefined },
},
});
};