Skip to content

Commit bb30ca4

Browse files
authored
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
1 parent 139e934 commit bb30ca4

File tree

32 files changed

+2394
-893
lines changed

32 files changed

+2394
-893
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: 'FastGPT-Test'
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
10+
permissions:
11+
# Required to checkout the code
12+
contents: read
13+
# Required to put a comment into the pull-request
14+
pull-requests: write
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: pnpm/action-setup@v4
19+
with:
20+
version: 10
21+
- name: 'Install Deps'
22+
run: pnpm install
23+
- name: 'Test'
24+
run: pnpm run test
25+
- name: 'Report Coverage'
26+
# Set if: always() to also generate the report if tests are failing
27+
# Only works if you set `reportOnFailure: true` in your vite config as specified above
28+
if: always()
29+
uses: davelosert/vitest-coverage-report-action@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ files/helm/fastgpt/fastgpt-0.1.0.tgz
4444
files/helm/fastgpt/charts/*.tgz
4545

4646
tmp/
47+
coverage

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,22 @@
1111
"initIcon": "node ./scripts/icon/init.js",
1212
"previewIcon": "node ./scripts/icon/index.js",
1313
"api:gen": "tsc ./scripts/openapi/index.ts && node ./scripts/openapi/index.js && npx @redocly/cli build-docs ./scripts/openapi/openapi.json -o ./projects/app/public/openapi/index.html",
14-
"create:i18n": "node ./scripts/i18n/index.js"
14+
"create:i18n": "node ./scripts/i18n/index.js",
15+
"test": "vitest run --exclude './projects/app/src/test/**'",
16+
"test:all": "vitest run",
17+
"test:workflow": "vitest run workflow"
1518
},
1619
"devDependencies": {
1720
"@chakra-ui/cli": "^2.4.1",
21+
"@vitest/coverage-v8": "^3.0.2",
1822
"husky": "^8.0.3",
19-
"lint-staged": "^13.3.0",
2023
"i18next": "23.11.5",
24+
"lint-staged": "^13.3.0",
2125
"next-i18next": "15.3.0",
22-
"react-i18next": "14.1.2",
2326
"prettier": "3.2.4",
27+
"react-i18next": "14.1.2",
28+
"vitest": "^3.0.2",
29+
"vitest-mongodb": "^1.0.1",
2430
"zhlint": "^0.7.4"
2531
},
2632
"lint-staged": {

projects/app/src/pages/api/v1/chat/utils.test.ts renamed to packages/service/core/ai/utils.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import '@/pages/api/__mocks__/base';
2-
import { parseReasoningStreamContent } from '@fastgpt/service/core/ai/utils';
1+
import { parseReasoningStreamContent } from './utils';
2+
import { expect, test } from 'vitest';
33

44
test('Parse reasoning stream content test', async () => {
55
const partList = [

packages/service/test/utils.ts

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)