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:
		
							parent
							
								
									11d6172e95
								
							
						
					
					
						commit
						3749c9b2af
					
				|  | @ -1,5 +1,4 @@ | ||||||
| name: Run Jest Tests | name: Run Unit Tests | ||||||
| 
 |  | ||||||
| on: | on: | ||||||
|   push: |   push: | ||||||
|     branches: |     branches: | ||||||
|  | @ -21,11 +20,5 @@ jobs: | ||||||
|     - name: Install dependencies |     - name: Install dependencies | ||||||
|       run: npm ci |       run: npm ci | ||||||
| 
 | 
 | ||||||
|     - name: Run Jest Test Suite |     - name: Run Vitest Suite | ||||||
|       run: npm test |       run: npm test | ||||||
|      |  | ||||||
|     - name: Publish Test Report |  | ||||||
|       if: always() |  | ||||||
|       uses: EnricoMi/publish-unit-test-result-action@v1 |  | ||||||
|       with: |  | ||||||
|         files: test-results/**/results.xml |  | ||||||
|  | @ -1,6 +1,8 @@ | ||||||
| import { ExportFormatV1, ExportFormatV2 } from '@/types/export'; | import { ExportFormatV1, ExportFormatV2 } from '@/types/export'; | ||||||
| import { OpenAIModels, OpenAIModelID } from '@/types/openai'; | import { OpenAIModels, OpenAIModelID } from '@/types/openai'; | ||||||
| import { DEFAULT_SYSTEM_PROMPT } from '@/utils/app/const'; | import { DEFAULT_SYSTEM_PROMPT } from '@/utils/app/const'; | ||||||
|  | import { it, describe, expect } from 'vitest'; | ||||||
|  | 
 | ||||||
| import { | import { | ||||||
|   cleanData, |   cleanData, | ||||||
|   isExportFormatV1, |   isExportFormatV1, | ||||||
|  |  | ||||||
|  | @ -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; |  | ||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										15
									
								
								package.json
								
								
								
								
							
							
						
						
									
										15
									
								
								package.json
								
								
								
								
							|  | @ -8,7 +8,8 @@ | ||||||
|     "start": "next start", |     "start": "next start", | ||||||
|     "lint": "next lint", |     "lint": "next lint", | ||||||
|     "format": "prettier --write .", |     "format": "prettier --write .", | ||||||
|     "test": "jest" |     "test": "vitest", | ||||||
|  |     "coverage": "vitest run --coverage" | ||||||
|   }, |   }, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@dqbd/tiktoken": "^1.0.2", |     "@dqbd/tiktoken": "^1.0.2", | ||||||
|  | @ -30,26 +31,20 @@ | ||||||
|   }, |   }, | ||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
|     "@tailwindcss/typography": "^0.5.9", |     "@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/node": "18.15.0", | ||||||
|     "@types/react": "18.0.28", |     "@types/react": "18.0.28", | ||||||
|     "@types/react-dom": "18.0.11", |     "@types/react-dom": "18.0.11", | ||||||
|     "@types/react-syntax-highlighter": "^15.5.6", |     "@types/react-syntax-highlighter": "^15.5.6", | ||||||
|     "@types/uuid": "^9.0.1", |     "@types/uuid": "^9.0.1", | ||||||
|  |     "@vitest/coverage-c8": "^0.29.7", | ||||||
|     "autoprefixer": "^10.4.14", |     "autoprefixer": "^10.4.14", | ||||||
|     "eslint": "8.36.0", |     "eslint": "8.36.0", | ||||||
|     "eslint-config-next": "13.2.4", |     "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", |     "postcss": "^8.4.21", | ||||||
|     "prettier": "^2.8.7", |     "prettier": "^2.8.7", | ||||||
|     "prettier-plugin-tailwindcss": "^0.2.5", |     "prettier-plugin-tailwindcss": "^0.2.5", | ||||||
|     "tailwindcss": "^3.2.7", |     "tailwindcss": "^3.2.7", | ||||||
|     "ts-jest": "^29.0.5", |     "typescript": "4.9.5", | ||||||
|     "ts-node": "^10.9.1", |     "vitest": "^0.29.7" | ||||||
|     "typescript": "4.9.5" |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,11 +1,7 @@ | ||||||
| { | { | ||||||
|   "compilerOptions": { |   "compilerOptions": { | ||||||
|     "target": "es5", |     "target": "es5", | ||||||
|     "lib": [ |     "lib": ["dom", "dom.iterable", "esnext"], | ||||||
|       "dom", |  | ||||||
|       "dom.iterable", |  | ||||||
|       "esnext" |  | ||||||
|     ], |  | ||||||
|     "allowJs": true, |     "allowJs": true, | ||||||
|     "skipLibCheck": true, |     "skipLibCheck": true, | ||||||
|     "strict": true, |     "strict": true, | ||||||
|  | @ -18,22 +14,11 @@ | ||||||
|     "isolatedModules": true, |     "isolatedModules": true, | ||||||
|     "jsx": "preserve", |     "jsx": "preserve", | ||||||
|     "incremental": true, |     "incremental": true, | ||||||
|  |     "types": ["vitest/globals"], | ||||||
|     "paths": { |     "paths": { | ||||||
|       "@/*": [ |       "@/*": ["./*"] | ||||||
|         "./*" |  | ||||||
|       ] |  | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   "include": [ |   "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], | ||||||
|     "next-env.d.ts", |   "exclude": ["node_modules"] | ||||||
|     "**/*.ts", |  | ||||||
|     "**/*.tsx" |  | ||||||
|   ], |  | ||||||
|   "exclude": [ |  | ||||||
|     "node_modules" |  | ||||||
|   ], |  | ||||||
|   "jest": { |  | ||||||
|     "preset": "ts-jest", |  | ||||||
|     "testEnvironment": "jsdom" |  | ||||||
|   } |  | ||||||
| } | } | ||||||
|  | @ -0,0 +1,10 @@ | ||||||
|  | import { defineConfig } from 'vite'; | ||||||
|  | import path from 'path'; | ||||||
|  | 
 | ||||||
|  | export default defineConfig({ | ||||||
|  |   resolve: { | ||||||
|  |     alias: { | ||||||
|  |       '@': path.resolve(__dirname, './'), | ||||||
|  |     }, | ||||||
|  |   }, | ||||||
|  | }); | ||||||
		Loading…
	
		Reference in New Issue