Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/migrate2vitest #1687

Merged
merged 18 commits into from
Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
},
"globals": {
"cy": "readonly",
"__VERSION__": true
"__VERSION__": true,
"vi": true
},
"plugins": [
"vue",
Expand Down Expand Up @@ -132,6 +133,7 @@
{
"files": [
"**/_example/*",
"**/__tests__/*",
"script/**/*",
"script/*",
"*.js",
Expand Down
2 changes: 1 addition & 1 deletion TEST_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ npm run test:unit

- 每个组件至少有两个单元测试文件,一个是测试源代码的单元测试文件 index.test.js,另一个则是测试组件示例代码的单元测试文件 demo.test.js
- 用例书写请使用:[vue-test-utils](https://vue-test-utils.vuejs.org/zh/)
- 断言库请使用:[https://jestjs.io/docs/en/expect](https://jestjs.io/docs/en/expect)
- 断言库请使用:[https://vitest.dev/api/#expect](https://vitest.dev/api/#expect)

#### 单元测试文件

Expand Down
36 changes: 15 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
},
"scripts": {
"update:coverage-badge": "node script/test/generate-coverage.js",
"cypress": "cypress run --config-file script/test/cypress.json",
"cypress-gui": "cypress open --config-file script/test/cypress.json",
"start": "cd site && npm run dev",
"dev": "cd site && npm run dev",
"site": "cd site && npm run build",
Expand All @@ -64,15 +62,13 @@
"lint": "npm run lint:tsc && eslint --ext .vue,.js,.ts,.tsx ./ --max-warnings 0",
"lint:tsc": "tsc --emitDeclarationOnly",
"generate:usage": "node script/generate-usage/index.js",
"test": "npm run test:unit && npm run test:node",
"test:demo": "node src/_common/test/script/generate-demo-test.js",
"test:update": "npm run test:unit-update && npm run test:node-update",
"test:unit": "jest --config script/test/jest.unit.conf.js",
"test:unit-update": "jest --config script/test/jest.unit.conf.js --updateSnapshot",
"test:node": "jest --config script/test/jest.ssr.conf.js",
"test:node-update": "jest --config script/test/jest.ssr.conf.js --updateSnapshot",
"test:watch": "jest --config script/test/jest.unit.conf.js --watch",
"test:coverage": "jest --config script/test/jest.unit.conf.js --coverage",
"test": "vitest run",
"test:update": "vitest run -u && npm run test:snap-update",
"test:unit-dev": "vitest",
"test:unit-gui": "vitest --ui",
"test:coverage": "vitest run --coverage",
"test:snap": "cross-env NODE_ENV=test-snap vitest run",
"test:snap-update": "cross-env NODE_ENV=test-snap vitest run -u",
"test:e2e": "cypress run --config-file script/test/cypress.json",
"test:e2e-gui": "cypress open --config-file script/test/cypress.json",
"test:build-files": "node script/test/build-files.js",
Expand Down Expand Up @@ -126,17 +122,19 @@
"@typescript-eslint/experimental-utils": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"@typescript-eslint/typescript-estree": "^5.4.0",
"@vitest/coverage-c8": "^0.24.3",
"@vitest/coverage-istanbul": "^0.24.3",
"@vitest/ui": "^0.24.3",
"@vue/babel-helper-vue-jsx-merge-props": "^1.2.1",
"@vue/babel-preset-jsx": "^1.2.4",
"@vue/eslint-config-typescript": "^9.1.0",
"@vue/test-utils": "^1.3.0",
"autoprefixer": "^9.7.6",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.3",
"babel-jest": "~29.1.0",
"babel-polyfill": "^6.26.0",
"c8": "^7.12.0",
"camelcase": "~6.3.0",
"canvas": "~2.10.1",
chaishi marked this conversation as resolved.
Show resolved Hide resolved
"cli-color": "^2.0.0",
"commitizen": "^4.0.3",
"cross-env": "^7.0.2",
Expand All @@ -146,19 +144,15 @@
"esbuild": "^0.14.9",
"eslint": "^7.1.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-vue": "^8.1.1",
"fs-extra": "^10.1.0",
"glob": "^8.0.3",
"gray-matter": "^4.0.3",
"husky": "^7.0.4",
"hyphenate": "^0.2.4",
"jest": "~29.1.2",
"jest-environment-jsdom": "~29.1.2",
"jest-html-reporter": "^3.4.2",
"jest-serializer-vue": "^2.0.2",
"jest-transform-stub": "^2.0.0",
"jest-watch-typeahead": "~2.2.0",
"jsdom": "^20.0.1",
"less": "^4.1.2",
"lint-staged": "^12.3.7",
"mockdate": "^3.0.2",
Expand All @@ -182,16 +176,16 @@
"tdesign-publish-cli": "^0.0.12",
"tdesign-site-components": "^0.11.1",
"tdesign-theme-generator": "^0.5.0",
"ts-jest": "~29.0.3",
"typescript": "~4.5.4",
"unplugin-vue2-script-setup": "^0.10.2",
"vite": "^2.7.6",
"vite-plugin-pwa": "^0.11.11",
"vite-plugin-tdoc": "^2.0.2",
"vite-plugin-vue2": "^1.9.0",
"vitest": "^0.24.3",
"vitest-fetch-mock": "^0.2.1",
"vue": "~2.6.14",
"vue-class-component": "^7.2.3",
"vue-jest": "^3.0.5",
"vue-router": "^3.5.3",
"vue-server-renderer": "~2.6.14",
"vue-template-compiler": "~2.6.14",
Expand Down
47 changes: 0 additions & 47 deletions script/test/jest.base.conf.js

This file was deleted.

7 changes: 0 additions & 7 deletions script/test/jest.ssr.conf.js

This file was deleted.

13 changes: 0 additions & 13 deletions script/test/jest.unit.conf.js

This file was deleted.

4 changes: 3 additions & 1 deletion script/test/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Vue from 'vue';
import VueCompositionAPI from '@vue/composition-api';
import TDesign from '@/src/index';

Vue.config.productionTip = true;
Vue.config.devtools = false;

Vue.use(VueCompositionAPI);
Vue.use(TDesign);
Vue.config.productionTip = false;
51 changes: 0 additions & 51 deletions src/affix/__tests__/__snapshots__/demo.test.js.snap

This file was deleted.

21 changes: 0 additions & 21 deletions src/affix/__tests__/demo.test.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ describe('Affix', () => {
const affixWrapper = wrapper.findComponent(Affix);
await affixWrapper.setData({ fixedTop: 10 });
expect(affixWrapper.find('.t-affix').selector).toBe('.t-affix');
wrapper.destroy();
});
});
});
Loading