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

refactor: migrate to vitest #723

Merged
merged 19 commits into from
May 14, 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
1 change: 1 addition & 0 deletions .github/workflows/typos-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ formated = "formated"
formate = "formate"
Colum = "Colum"
ba = "ba"
ded = "ded"
12 changes: 0 additions & 12 deletions examples/breadcrumbItem/breadcrumbItem.md

This file was deleted.

6 changes: 0 additions & 6 deletions examples/breadcrumbItem/demos/base.vue

This file was deleted.

6 changes: 0 additions & 6 deletions examples/breadcrumbItem/demos/overlay.vue

This file was deleted.

18 changes: 0 additions & 18 deletions examples/breadcrumbItem/usage/index.vue

This file was deleted.

118 changes: 0 additions & 118 deletions examples/breadcrumbItem/usage/props.json

This file was deleted.

4 changes: 2 additions & 2 deletions examples/select/demos/custom-options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ const options = [
{ label: '用户九', value: '9', description: '这是一段用户描述信息,可自定义内容' },
];

const value1 = ref([]);
const value2 = ref([]);
const value1 = ref('');
const value2 = ref('');
const optionRender = (h, option) => (
<div class="tdesign-demo__user-option">
<img src="https://tdesign.gtimg.com/site/avatar.jpg" />
Expand Down
37 changes: 16 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,13 @@
"lint:fix": "eslint --ext .vue,.js,.ts,.tsx ./src --max-warnings 0 --fix",
"lint": "npm run lint:tsc && eslint --ext .vue,.js,.ts,.tsx ./src --max-warnings 0",
"lint:tsc": "tsc --emitDeclarationOnly",
"test": "npm run test:demo && npm run test:unit && npm run test:node",
"test:demo": "node src/_common/test/script/generate-demo-test.js",
"test:update": "npm run test:demo && npm run test:unit-update && npm run test:node-update",
"test:unit": "jest --maxWorkers=4 --config script/test/jest.unit.conf.js",
"test:unit-update": "jest --maxWorkers=4 --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": "npm run test:unit && npm run test:snap",
"test:unit": "vitest run --config site/vite.config.js",
"test:update": "vitest run --config site/vite.config.js -u && cross-env NODE_ENV=test-snap vitest run --config site/vite.config.js -u",
"test:unit-dev": "vitest --config site/vite.config.js",
"test:unit-gui": "vitest --config site/vite.config.js --ui",
"test:unit-coverage": "vitest run --config site/vite.config.js --coverage",
"test:snap": "cross-env NODE_ENV=test-snap vitest run --config site/vite.config.js",
"test:e2e": "cypress run --config-file script/test/cypress.json",
"test:e2e-gui": "cypress open --config-file script/test/cypress.json",
"changelog": "node script/generate-changelog.js",
Expand All @@ -75,9 +73,9 @@
"@babel/runtime": "^7.14.8",
"@popperjs/core": "^2.9.3",
"@types/lodash": "^4.14.175",
"@types/sortablejs": "^1.10.7",
"@types/tinycolor2": "^1.4.3",
"@types/validator": "^13.6.3",
"@types/sortablejs": "^1.10.7",
"dayjs": "^1.9.7",
"jsx-to-string": "^1.4.0",
"lodash": "^4.17.15",
Expand Down Expand Up @@ -107,15 +105,16 @@
"@types/raf": "^3.4.0",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"@vitejs/plugin-vue": "^2.0.1",
"@vitejs/plugin-vue": "^2.3.1",
"@vitejs/plugin-vue-jsx": "^1.3.3",
"@vitest/ui": "^0.9.4",
"@vue/compiler-sfc": "^3.2.26",
"@vue/eslint-config-typescript": "^10.0.0",
"@vue/server-renderer": "^3.2.4",
"@vue/test-utils": "^2.0.0-rc.12",
"@vue/test-utils": "^2.0.0-rc.21",
"autoprefixer": "^10.4.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.0.0",
"c8": "^7.11.2",
"camelcase": "^6.2.1",
"cli-color": "^2.0.1",
"clipboard": "^2.0.6",
Expand All @@ -134,11 +133,7 @@
"gray-matter": "^4.0.3",
"husky": "^7.0.4",
"ignore": "^5.1.9",
"jest": "^26.6.3",
"jest-html-reporter": "^3.1.3",
"jest-serializer-vue": "^2.0.2",
"jest-transform-stub": "^2.0.0",
"jest-watch-typeahead": "^0.6.0",
"jsdom": "^19.0.0",
"less": "^4.1.2",
"lint-staged": "^12.1.2",
"mockdate": "^3.0.5",
Expand All @@ -162,13 +157,13 @@
"tdesign-icons-view": "0.1.0",
"tdesign-publish-cli": "^0.0.9",
"tdesign-site-components": "^0.9.9",
"ts-jest": "^26.0.0",
"typescript": "^4.5.4",
"vite": "^2.7.7",
"vite": "^2.9.5",
"vite-plugin-pwa": "^0.12.0",
"vite-plugin-tdoc": "^2.0.2",
"vitest": "^0.9.4",
"vitest-fetch-mock": "^0.1.0",
"vue": "^3.2.26",
"vue-jest": "^5.0.0-alpha.7",
"vue-router": "^4.0.12",
"vue-tsc": "^0.34.11",
"workbox-precaching": "^6.4.1"
Expand Down
11 changes: 0 additions & 11 deletions script/init/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@ function getToBeCreatedFiles(component) {
desc: 'e2e test',
files: [`${component}.spec.js`],
},
// ['test/ssr']: {
// // no delete the whole folder, just delete these files in 'deleteFiles'.
// deleteFiles: [`test/ssr/${component}.test.js`],
// desc: 'ssr test',
// files: [
// {
// file: `${component}.test.js`,
// template: 'ssr.demo.test.tpl',
// },
// ],
// },
};
}

Expand Down
45 changes: 0 additions & 45 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.

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

This file was deleted.

8 changes: 6 additions & 2 deletions script/test/setup.js → script/test/test-setup.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { config } from '@vue/test-utils';
import { createApp } from 'vue';
import { renderToString } from '@vue/server-renderer';
import createFetchMock from 'vitest-fetch-mock';
import { vi } from 'vitest';
import TDesign from '@/src/index';

const fetchMock = createFetchMock(vi);
fetchMock.enableMocks();

config.global.plugins = [TDesign];

config.global.createSSRApp = (comp) => {
const app = createApp(comp);
app.config.globalProperties.$route = {};
app.use(TDesign);
const html = renderToString(app);
return html;
return renderToString(app);
};
Loading