chore: migrate to vitest for 10x faster tests (#257)

* chore migrate to vitest

* chore: cleanup jest stuff

* chore: install the coverage dep
This commit is contained in:
Simon Holmes 2023-03-28 10:22:58 +00:00 committed by GitHub
parent 11d6172e95
commit 3749c9b2af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1691 additions and 5953 deletions

View File

@ -1,5 +1,4 @@
name: Run Jest Tests
name: Run Unit Tests
on:
push:
branches:
@ -21,11 +20,5 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Run Jest Test Suite
- name: Run Vitest Suite
run: npm test
- name: Publish Test Report
if: always()
uses: EnricoMi/publish-unit-test-result-action@v1
with:
files: test-results/**/results.xml

View File

@ -1,6 +1,8 @@
import { ExportFormatV1, ExportFormatV2 } from '@/types/export';
import { OpenAIModels, OpenAIModelID } from '@/types/openai';
import { DEFAULT_SYSTEM_PROMPT } from '@/utils/app/const';
import { it, describe, expect } from 'vitest';
import {
cleanData,
isExportFormatV1,

View File

@ -1,22 +0,0 @@
import type { Config } from 'jest';
const config: Config = {
testEnvironment: 'jest-environment-jsdom',
verbose: true,
preset: 'ts-jest',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
},
reporters: [
'default',
[
'jest-junit',
{
outputDirectory: 'test-results/jest',
outputName: 'results.xml',
},
],
],
};
export default config;

7557
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,8 @@
"start": "next start",
"lint": "next lint",
"format": "prettier --write .",
"test": "jest"
"test": "vitest",
"coverage": "vitest run --coverage"
},
"dependencies": {
"@dqbd/tiktoken": "^1.0.2",
@ -30,26 +31,20 @@
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.9",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@types/jest": "^29.5.0",
"@types/node": "18.15.0",
"@types/react": "18.0.28",
"@types/react-dom": "18.0.11",
"@types/react-syntax-highlighter": "^15.5.6",
"@types/uuid": "^9.0.1",
"@vitest/coverage-c8": "^0.29.7",
"autoprefixer": "^10.4.14",
"eslint": "8.36.0",
"eslint-config-next": "13.2.4",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-junit": "^15.0.0",
"postcss": "^8.4.21",
"prettier": "^2.8.7",
"prettier-plugin-tailwindcss": "^0.2.5",
"tailwindcss": "^3.2.7",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"typescript": "4.9.5"
"typescript": "4.9.5",
"vitest": "^0.29.7"
}
}

View File

@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
@ -18,22 +14,11 @@
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"types": ["vitest/globals"],
"paths": {
"@/*": [
"./*"
]
"@/*": ["./*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
],
"jest": {
"preset": "ts-jest",
"testEnvironment": "jsdom"
}
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

10
vitest.config.ts Normal file
View File

@ -0,0 +1,10 @@
import { defineConfig } from 'vite';
import path from 'path';
export default defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, './'),
},
},
});