mirror of
https://github.com/immich-app/immich.git
synced 2026-03-23 04:29:12 +03:00
feat: vitest 4
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
import { Kysely } from 'kysely';
|
||||
import { ConfigRepository } from 'src/repositories/config.repository';
|
||||
import { DatabaseRepository } from 'src/repositories/database.repository';
|
||||
import { LoggingRepository } from 'src/repositories/logging.repository';
|
||||
import { DB } from 'src/schema';
|
||||
import { getKyselyConfig } from 'src/utils/database';
|
||||
import { Migrator } from '@immich/sql-tools';
|
||||
import { join } from 'node:path';
|
||||
import { GenericContainer, Wait } from 'testcontainers';
|
||||
|
||||
const globalSetup = async () => {
|
||||
@@ -40,13 +36,15 @@ const globalSetup = async () => {
|
||||
|
||||
process.env.IMMICH_TEST_POSTGRES_URL = postgresUrl;
|
||||
|
||||
const db = new Kysely<DB>(getKyselyConfig({ connectionType: 'url', url: postgresUrl }));
|
||||
const migrator = new Migrator({
|
||||
allowUnorderedMigrations: false,
|
||||
connectionParams: { connectionType: 'url', url: postgresUrl },
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
migrationFolder: join(__dirname, '../../src/schema/migrations'),
|
||||
});
|
||||
await migrator.runMigrations();
|
||||
|
||||
const configRepository = new ConfigRepository();
|
||||
const logger = LoggingRepository.create();
|
||||
await new DatabaseRepository(db, logger, configRepository).runMigrations();
|
||||
|
||||
await db.destroy();
|
||||
await migrator.destroy();
|
||||
};
|
||||
|
||||
export default globalSetup;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import swc from 'unplugin-swc';
|
||||
import tsconfigPaths from 'vite-tsconfig-paths';
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
const serverRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
@@ -19,5 +17,7 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [swc.vite(), tsconfigPaths()],
|
||||
resolve: {
|
||||
tsconfigPaths: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import swc from 'unplugin-swc';
|
||||
import tsconfigPaths from 'vite-tsconfig-paths';
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
const serverRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
tsconfigPaths: true,
|
||||
},
|
||||
test: {
|
||||
name: 'server:unit',
|
||||
root: serverRoot,
|
||||
@@ -31,5 +32,4 @@ export default defineConfig({
|
||||
TZ: 'UTC',
|
||||
},
|
||||
},
|
||||
plugins: [swc.vite(), tsconfigPaths()],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user