chore: vitest support (#4026)

* chore: vitest

* chore: move test files

* chore: support vitest

* fix: exclude test files

* chore(ci): add test workflow

* feat: remove read env
This commit is contained in:
Finley Ge
2025-03-12 19:27:53 +08:00
committed by GitHub
parent 139e934345
commit bb30ca4859
32 changed files with 2393 additions and 892 deletions

18
test/test.ts Normal file
View File

@@ -0,0 +1,18 @@
import { MongoUser } from '@fastgpt/service/support/user/schema';
import { it, expect } from 'vitest';
it('should be a test', async () => {
expect(1).toBe(1);
});
it('should be able to connect to mongo', async () => {
expect(global.mongodb).toBeDefined();
expect(global.mongodb?.connection.readyState).toBe(1);
await MongoUser.create({
username: 'test',
password: '123456'
});
const user = await MongoUser.findOne({ username: 'test' });
expect(user).toBeDefined();
expect(user?.username).toBe('test');
});