Skip to content

Commit

Permalink
Merge pull request #19 from ant-design/fix/tslint
Browse files Browse the repository at this point in the history
test: init test config and add ci workflow
  • Loading branch information
yutingzhao1991 authored Oct 5, 2023
2 parents 19e7fba + 8e027ad commit 4bbe52e
Show file tree
Hide file tree
Showing 12 changed files with 3,741 additions and 4,118 deletions.
1 change: 1 addition & 0 deletions .dumi/app.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-ignore
import { MockProvider, Web3ConfigProvider } from '../packages/web3/dist/esm'; // use the same provider with demo in dumi

const provider = new MockProvider();
Expand Down
1 change: 0 additions & 1 deletion .dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export default defineConfig({
},
],
},
mfsu: false,
// TODO: remove after get a domain
publicPath: '/ant-design-web3/',
base: '/ant-design-web3',
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on:
pull_request:
types:
- opened
- synchronize

jobs:
ci:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: ci
run: |
npm i pnpm -g
pnpm install
pnpm run ci
26 changes: 11 additions & 15 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
// preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['<rootDir>/packages/**/*.test.ts'],
testEnvironment: 'jsdom',
testMatch: ['<rootDir>/packages/**/*.test.(ts|tsx)'],
testPathIgnorePatterns: ['/node_modules/'],
testTimeout: 3e4,
transformIgnorePatterns: [`/node_modules/(?!${[].join('|')})`],
transform: {
'^.+\\.ts$': [
'^.+\\.(ts|tsx)$': [
'@swc/jest',
{
jsc: {
// config doc: https://swc.rs/docs/configuration/compilation
parser: {
syntax: 'typescript',
decorators: true,
dynamicImport: true,
},
transform: null,
transform: {
react: {
runtime: 'automatic',
},
},
},
},
],
// '^.+\\.ts$': ['ts-jest', { diagnostics: false }],
},
setupFiles: ['<rootDir>/scripts/jest-setup.js'],
setupFiles: ['<rootDir>/tests/setup.js'],
collectCoverageFrom: ['<rootDir>/packages/*/src/**/*.ts'],
coveragePathIgnorePatterns: ['/node_modules/', '/(.*)mock(.*)/'],
reporters: ['default', ['jest-junit', { outputDirectory: 'coverage' }]],
coverageReporters: [
// 'clover',
// 'json',
'json-summary',
['text', { skipFull: true }],
'cobertura',
// 'html-spa',
],
coverageReporters: ['json-summary', ['text', { skipFull: true }], 'cobertura'],
};
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
"release": "changeset version && changeset publish",
"release:alpha": "changeset version --snapshot alpha && changeset publish --tag alpha",
"release:beta": "changeset version --snapshot beta && changeset publish --tag beta",
"ci": "npm run lint:eslint && npm run lint:prettier && npm run test:ci",
"ci": "npm run lint && npm run test:ci && npm run build",
"test": "jest",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",
"test:ci": "jest --coverage --maxWorkers=4 --forceExit",
"lint": "pnpm run \"/^lint:.+/\"",
"lint:eslint": "eslint --quiet --fix --ext .ts,.js .",
"lint:prettier": "prettier --loglevel warn --write '**/*.{ts,tsx,js,jsx,json,md}'",
"lint:ts": "tsc --noEmit",
"clean": "pnpm run \"/^clean:.+/\"",
"clean:module": "rimraf --glob ./node_modules ./packages/*/node_modules ./examples/*/node_modules",
"clean:dist": "rimraf --glob ./packages/*/dist ./examples/*/dist",
Expand All @@ -40,14 +41,17 @@
"@changesets/cli": "^2.26.1",
"@swc/core": "^1.3.61",
"@swc/jest": "^0.2.26",
"@testing-library/react": "^14.0.0",
"@types/jest": "^29.5.1",
"@types/node": "^16.6.1",
"@types/react": "^18.2.20",
"@umijs/fabric": "^2.14.1",
"dumi": "^2.2.6",
"eslint": "^7.32.0",
"father": "^4.1.9",
"husky": "^8.0.3",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.7.0",
"jest-junit": "^16.0.0",
"lint-staged": "^13.2.2",
"prettier": "^2.8.8",
Expand All @@ -63,8 +67,5 @@
"engines": {
"node": ">=16"
},
"repository": "[email protected]:antchain-fe/ant-design-web3.git",
"dependencies": {
"@types/react": "^18.2.20"
}
"repository": "[email protected]:antchain-fe/ant-design-web3.git"
}
2 changes: 1 addition & 1 deletion packages/web3/src/Address/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export const Address: React.FC<AddressProps> = (props) => {
return null;
}

return ellipsis ? address?.slice(0, 6) + '...' + address?.slice(-4) : address;
return <>{ellipsis ? address?.slice(0, 6) + '...' + address?.slice(-4) : address}</>;
};
8 changes: 8 additions & 0 deletions packages/web3/src/ConnectButton/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ConnectButton } from '..';
import { render } from '@testing-library/react';

describe('ConnectButton', () => {
it('mount correctly', () => {
expect(() => render(<ConnectButton />)).not.toThrow();
});
});
2 changes: 1 addition & 1 deletion packages/web3/src/ConnectModal/demos/simple.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ConnectModal } from '@ant-design/web3';
import { Button } from 'antd';
import React from 'react';
import type { ConnectModalProps, DefaultGuide, Wallet } from '../interface';
import type { DefaultGuide, Wallet } from '../interface';

export default () => {
const [open, setOpen] = React.useState(false);
Expand Down
2 changes: 1 addition & 1 deletion packages/web3/src/hooks/useCurrentAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function useCurrentAccount() {
setCurrentAccount(account);
};
React.useEffect(() => {
refresh;
refresh();
});
return {
account: currentAccount,
Expand Down
Loading

0 comments on commit 4bbe52e

Please sign in to comment.