2
0
Эх сурвалжийг харах

refactor: replace jest with vitest (#173)

Alex Kanunnikov 4 сар өмнө
parent
commit
1614f35c00

+ 0 - 1
.eslintrc.cjs

@@ -3,7 +3,6 @@ module.exports = {
     commonjs: true,
     es2021: true,
     node: true,
-    jest: true,
   },
   parser: '@typescript-eslint/parser',
   parserOptions: {

+ 1 - 1
.github/workflows/test.yaml

@@ -20,6 +20,6 @@ jobs:
       - run: npm test -- --coverage --coverageDirectory=coverage/results-${{ matrix.node-version }}
       - uses: actions/upload-artifact@v3
         with:
-          name: jest-results-${{ matrix.node-version }}
+          name: vitest-results-${{ matrix.node-version }}
           path: coverage/results-${{ matrix.node-version }}/*.xml
         if: ${{ always() }}

+ 0 - 20
jest.config.cjs

@@ -1,20 +0,0 @@
-/** @type {import('ts-jest').JestConfigWithTsJest} */
-module.exports = {
-  preset: 'ts-jest',
-  testEnvironment: 'node',
-  maxWorkers: 1,
-  extensionsToTreatAsEsm: ['.ts'],
-  moduleNameMapper: {
-    '^(\\.{1,2}/.*)\\.js$': '$1',
-  },
-  transform: {
-    // '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
-    // '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
-    '^.+\\.tsx?$': [
-      'ts-jest',
-      {
-        useESM: true,
-      },
-    ],
-  },
-}

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 341 - 658
package-lock.json


+ 2 - 5
package.json

@@ -20,7 +20,7 @@
   },
   "scripts": {
     "format": "prettier --write .",
-    "test": "jest --config=jest.config.cjs ./test/*",
+    "test": "vitest --run",
     "build": "unbuild",
     "lint": "eslint ./src/*",
     "prepublishOnly": "npm run build"
@@ -34,15 +34,12 @@
   "license": "MIT",
   "devDependencies": {
     "@swc/core": "^1.3.14",
-    "@types/jest": "^29.2.2",
     "@types/whatwg-fetch": "^0.0.33",
     "@typescript-eslint/eslint-plugin": "^5.42.1",
     "@typescript-eslint/parser": "^5.42.1",
     "eslint": "^8.29.0",
-    "eslint-plugin-jest": "^27.1.4",
-    "jest": "^29.3.0",
+    "vitest": "^2.1.6",
     "prettier": "^3.2.4",
-    "ts-jest": "^29.0.3",
     "typescript": "^5.3.2",
     "unbuild": "^2.0.0"
   },

+ 2 - 1
test/index.spec.ts

@@ -1,3 +1,4 @@
+import { describe, it, expect } from 'vitest'
 import { formatHost } from '../src/utils'
 
 describe('formatHost Function Tests', () => {
@@ -57,7 +58,7 @@ describe('formatHost Function Tests', () => {
     expect(formatHost('example.com:56789/')).toBe('http://example.com:56789')
   })
 
-  it('should handle traling slash with only a port', () => {
+  it('should handle trailing slash with only a port', () => {
     expect(formatHost(':56789/')).toBe('http://127.0.0.1:56789')
   })
 })

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно