Skip to content

Commit

Permalink
🧪 feat: upgrade jest to vitest (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdsuwwz authored Aug 6, 2023
1 parent 7c0397c commit 396ed70
Show file tree
Hide file tree
Showing 10 changed files with 352 additions and 1,581 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module.exports = {
browser: true,
node: true,
es2021: true,
jest: true,
'vue/setup-compiler-macros': true
},
parser: 'vue-eslint-parser',
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

[![Deploy](https://github.com/pdsuwwz/vite-ts-starter/workflows/gh-pages/badge.svg)](https://github.com/pdsuwwz/vite-ts-starter/actions/workflows/deploy.yml)
[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/pdsuwwz/vite-ts-starter/deploy.yml?branch=main)](https://github.com/pdsuwwz/vite-ts-starter/deployments/activity_log?environment=github-pages)
[![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest)
[![thanks](https://badgen.net/badge/thanks/♥/pink)](https://github.com/pdsuwwz)
[![License](https://img.shields.io/github/license/pdsuwwz/vite-ts-starter?color=blue)](https://github.com/pdsuwwz/vite-ts-starter/blob/main/LICENSE)

Expand Down Expand Up @@ -31,7 +30,7 @@
* 支持 __Vite 4 + Vue 3 + TypeScript__
* UI 框架: __Element Plus 2.x__
* 状态管理: __Vuex 4__
* 单元测试框架: __Jest__
* 单元测试框架: ~~__Jest__~~ 升级为 __Vitest__
* 内置 __ESlint____Stylelint__, 可在此基础上扩展你想要的 Lint 配置规范
* 内置封装了一个**可能比较好用的** Axios , 需要时配合 Vuex Actions 一起食用
* 封装了 \<IconFont \/> 组件, 可直接使用 IconFont 图标
Expand Down
4 changes: 1 addition & 3 deletions __tests__/IconFont.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**
* @jest-environment jsdom
*/
import { describe, expect, it } from 'vitest'
import { mount } from '@vue/test-utils'
import IconFontComponent from '@/components/IconFont/index.vue'

Expand Down
4 changes: 1 addition & 3 deletions __tests__/hello.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**
* @jest-environment jsdom
*/
import { expect, test } from 'vitest'
import { mount } from '@vue/test-utils'
import HelloWorld from '@/components/HelloWorld/index.vue'

Expand Down
2 changes: 2 additions & 0 deletions __tests__/sum.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

test('plus test', () => {
expect(2 + 3).toBe(5)
})
44 changes: 0 additions & 44 deletions jest.config.js

This file was deleted.

21 changes: 7 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"preview": "vite preview --host",
"lint": "eslint ./src --ext .js,.ts,.jsx,.tsx,.vue",
"lint:fix": "eslint --fix --cache --ext .js,.ts,.jsx,.tsx,.vue ./src",
"test": "jest",
"test:coverage": "jest --coverage",
"test": "vitest",
"test:coverage": "vitest --coverage",
"stylelint": "stylelint .scss, .vue ./src",
"stylelint:fix": "stylelint --fix .scss, .vue ./src"
},
Expand All @@ -26,8 +26,8 @@
"vue-next",
"vite",
"jest",
"vitest",
"typescript",
"vue3-jest",
"admin",
"example",
"template",
Expand Down Expand Up @@ -65,29 +65,23 @@
"devDependencies": {
"@babel/core": "^7.22.9",
"@babel/preset-env": "^7.22.9",
"@sucrase/jest-plugin": "^3.0.0",
"@types/jest": "29.5.3",
"@types/js-cookie": "^3.0.3",
"@types/lodash": "^4.14.196",
"@types/node": "^20.4.8",
"@types/nprogress": "^0.2.0",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"@vitejs/plugin-vue": "^4.2.3",
"@vitest/coverage-v8": "^0.34.1",
"@vue/compiler-sfc": "^3.3.4",
"@vue/test-utils": "2.4.1",
"@vue/vue3-jest": "^29.2.4",
"babel-jest": "^29.6.2",
"babel-plugin-transform-vite-meta-env": "^1.0.3",
"cross-env": "^7.0.3",
"eslint": "^8.46.0",
"eslint-plugin-html": "7.1.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-vue": "9.16.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.6.2",
"jest-environment-jsdom": "^29.6.2",
"jest-transform-stub": "^2.0.0",
"jsdom": "^22.1.0",
"postcss": "^8.4.27",
"postcss-html": "^1.5.0",
"postcss-scss": "^4.0.6",
Expand All @@ -98,9 +92,8 @@
"stylelint-config-recommended-vue": "^1.5.0",
"stylelint-config-standard": "^34.0.0",
"stylelint-config-standard-scss": "10.0.0",
"sucrase": "^3.34.0",
"ts-jest": "29.1.1",
"typescript": "^5.1.6",
"vite": "^4.4.8"
"vite": "^4.4.8",
"vitest": "^0.34.1"
}
}
Loading

0 comments on commit 396ed70

Please sign in to comment.