Skip to content

Commit

Permalink
Merge pull request alibaba#993 from jaw52/build_vitest
Browse files Browse the repository at this point in the history
build(单元测试): 优化配置,fix引入路径问题,支持覆盖率生成
  • Loading branch information
siyi98 authored Dec 19, 2022
2 parents ccf0262 + 52b18aa commit 733506c
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 12 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
},
"devDependencies": {
"@babel/core": "^7.17.2",
"@babel/plugin-transform-react-jsx": "^7.19.0",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"@jest/types": "^27.5.1",
Expand All @@ -53,6 +54,7 @@
"@umijs/preset-react": "1.x",
"@umijs/test": "^3.0.5",
"@vitejs/plugin-react": "^3.0.0",
"@vitest/coverage-c8": "^0.25.8",
"@vitest/ui": "^0.25.7",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
"antd": "^4.x",
Expand Down
7 changes: 4 additions & 3 deletions packages/form-render/__tests__/demo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import FormRender, { useForm } from '../es';
import { listSchema, normalSchema } from './schema';
import * as React from 'react';
import { useState } from 'react';
import FormRender, { useForm } from '../src/index';
import { normalSchema } from './schema';

const SimpleForm = () => {
const form = useForm();
Expand Down
5 changes: 3 additions & 2 deletions packages/form-render/__tests__/form-demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState } from 'react';
import FormRender, { useForm } from '../es';
import * as React from 'react';
import { useState } from 'react';
import FormRender, { useForm } from '../src/index';

const schema = {
type: 'object',
Expand Down
2 changes: 1 addition & 1 deletion packages/form-render/__tests__/form-fields.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, test, afterAll, expect } from 'vitest';
import React from 'react';
import * as React from 'react';
import '@testing-library/jest-dom';
import { render, act, cleanup } from '@testing-library/react';
import Demo from './form-demo';
Expand Down
3 changes: 1 addition & 2 deletions packages/form-render/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
"prepare": "npm run build",
"prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
"postpublish": "git push --tags",
"test": "umi-test",
"test:coverage": "umi-test --coverage"
"test:ui": "vitest --ui"
},
"lint-staged": {
"*.{js,jsx,less,md,json}": [
Expand Down
2 changes: 1 addition & 1 deletion packages/table-render/__tests__/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, test, afterAll, expect } from 'vitest';
import { describe, expect, test } from 'vitest';
import { getDate, getDateTime, getMoneyType, isObj } from '../src/utils';

describe('Test TableRender valueType', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/table-render/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"postpublish": "git push --tags",
"site": "dumi build",
"start": "dumi dev",
"test": "umi-test",
"test:coverage": "umi-test --coverage"
"test:ui": "vitest --ui"
},
"lint-staged": {
"*.{js,jsx,less,md,json}": [
Expand Down
8 changes: 7 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';

export default defineConfig({
plugins: [react()],
plugins: [
react({
babel: {
plugins: ['@babel/plugin-transform-react-jsx'],
},
}) as any,
],
test: {
globals: true,
environment: 'jsdom',
Expand Down

0 comments on commit 733506c

Please sign in to comment.