Skip to content

Commit 55701df

Browse files
gin-lslthinkasany
andauthored
fix(test): coverage include files wrong (#1027)
* fix(test): coverage include files wrong * Update vitest.config.mts Co-authored-by: thinkasany <[email protected]> * Update vitest.config.mts * Update vitest.config.mts * test: ignore coverage for some files * chore: format --------- Co-authored-by: thinkasany <[email protected]>
1 parent 671c20f commit 55701df

File tree

31 files changed

+40
-8
lines changed

31 files changed

+40
-8
lines changed

packages/bitcoin/src/adapter/wallets/okx.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
import type { Account, Balance } from '@ant-design/web3-common';
23

34
import { NoAddressError, NoProviderError } from '../../error';

packages/bitcoin/src/adapter/wallets/unisat.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
import type { Account, Balance } from '@ant-design/web3-common';
23

34
import { NoAddressError, NoProviderError } from '../../error';

packages/bitcoin/src/adapter/wallets/xverse.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
import type { Account, Balance } from '@ant-design/web3-common';
23
import { AddressPurpose, getProviderById, request } from 'sats-connect';
34

packages/bitcoin/src/error.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
export class NoProviderError extends Error {
23
name: string;
34

packages/bitcoin/src/provider/__tests__/utils.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
import type { FC } from 'react';
23
import { render } from '@testing-library/react';
34

packages/bitcoin/src/wallets/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
import { metadata_OkxWallet, metadata_Unisat, metadata_Xverse } from '@ant-design/web3-assets';
23

34
import { OkxBitcoinWallet, UnisatBitcoinWallet, XverseBitcoinWallet } from '../adapter';

packages/common/src/utils/warning.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
import * as React from 'react';
23
import rcWarning, { resetWarned as rcResetWarned } from 'rc-util/lib/warning';
34

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
/* v8 ignore start */
12
export * from './use-web3js';

packages/eth-web3js/src/hooks/use-web3js.ts

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Chain, Client, Transport } from 'viem';
33
import { useConnectorClient, type Config } from 'wagmi';
44
import { Web3 } from 'web3';
55

6+
/* v8 ignore next 7 */
67
export const clientToWeb3js = (client: Client<Transport, Chain>): Web3 => {
78
const { transport } = client;
89
if (transport.type === 'fallback') {
@@ -13,5 +14,6 @@ export const clientToWeb3js = (client: Client<Transport, Chain>): Web3 => {
1314

1415
export function useWeb3js(): Web3 | null {
1516
const { data: client } = useConnectorClient<Config>();
17+
/* v8 ignore next */
1618
return useMemo(() => (client ? clientToWeb3js(client) : null), [client]);
1719
}

packages/eth-web3js/src/wagmi.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
export * from 'wagmi';
23
export * as actions from 'wagmi/actions';
34
export * as chains from 'wagmi/chains';

packages/ethers-v5/src/hooks/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
/* v8 ignore start */
12
export * from './use-ethers-provider';
23
export * from './use-ethers-signer';

packages/ethers-v5/src/hooks/use-ethers-provider.ts

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export function clientToProvider(client: Client<Transport, Chain>) {
1111
ensAddress: chain.contracts?.ensRegistry?.address,
1212
};
1313
if (transport.type === 'fallback')
14+
/* v8 ignore next 5 */
1415
return new providers.FallbackProvider(
1516
(transport.transports as ReturnType<Transport>[]).map(
1617
({ value }) => new providers.JsonRpcProvider(value?.url, network),
@@ -21,5 +22,6 @@ export function clientToProvider(client: Client<Transport, Chain>) {
2122

2223
export function useEthersProvider() {
2324
const client = useClient<Config>();
25+
/* v8 ignore next */
2426
return useMemo(() => (client ? clientToProvider(client) : null), [client]);
2527
}

packages/ethers-v5/src/hooks/use-ethers-signer.ts

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { providers } from 'ethers';
33
import type { Account, Chain, Client, Transport } from 'viem';
44
import { useConnectorClient, type Config } from 'wagmi';
55

6+
/* v8 ignore next 11 */
67
export function clientToSigner(client: Client<Transport, Chain, Account>) {
78
const { account, chain, transport } = client;
89
const network = {
@@ -17,5 +18,6 @@ export function clientToSigner(client: Client<Transport, Chain, Account>) {
1718

1819
export function useEthersSigner() {
1920
const { data: client } = useConnectorClient<Config>();
21+
/* v8 ignore next */
2022
return useMemo(() => (client ? clientToSigner(client) : null), [client]);
2123
}

packages/ethers-v5/src/provider.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
/* v8 ignore start */
12
export * from '@ant-design/web3-ethers/provider';

packages/ethers-v5/src/wagmi.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
/* v8 ignore start */
12
export * from '@ant-design/web3-ethers/wagmi';

packages/ethers-v5/src/wallets.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
/* v8 ignore start */
12
export * from '@ant-design/web3-ethers/wallets';

packages/ethers/src/hooks/use-ethers-provider.ts

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export function clientToProvider(client: Client<Transport, Chain>) {
1010
name: chain.name,
1111
ensAddress: chain.contracts?.ensRegistry?.address,
1212
};
13+
14+
/* v8 ignore next 7 */
1315
if (transport.type === 'fallback') {
1416
const providers = (transport.transports as ReturnType<Transport>[]).map(
1517
({ value }) => new JsonRpcProvider(value?.url, network),
@@ -22,5 +24,6 @@ export function clientToProvider(client: Client<Transport, Chain>) {
2224

2325
export function useEthersProvider() {
2426
const client = useClient<Config>();
27+
/* v8 ignore next */
2528
return useMemo(() => (client ? clientToProvider(client) : null), [client]);
2629
}

packages/ethers/src/hooks/use-ethers-signer.ts

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { BrowserProvider, JsonRpcSigner } from 'ethers';
33
import type { Account, Chain, Client, Transport } from 'viem';
44
import { useConnectorClient, type Config } from 'wagmi';
55

6+
/* v8 ignore next 13 */
67
export function clientToSigner(client: Client<Transport, Chain, Account>) {
78
const { account, chain, transport } = client;
89
const network = chain
@@ -19,5 +20,6 @@ export function clientToSigner(client: Client<Transport, Chain, Account>) {
1920

2021
export function useEthersSigner() {
2122
const { data: client } = useConnectorClient<Config>();
23+
/* v8 ignore next */
2224
return useMemo(() => (client ? clientToSigner(client) : null), [client]);
2325
}

packages/ethers/src/wagmi.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
export * from 'wagmi';
23
export * as actions from 'wagmi/actions';
34
export * as chains from 'wagmi/chains';

packages/solana/src/solana-provider/useWalletConnectProvider.ts

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const useWalletConnectProvider = (walletConnect?: UniversalProviderOpts)
1414
);
1515
const promiseResolvesRef = useLatest(promiseResolves);
1616

17+
/* v8 ignore next 9 */
1718
const getWalletConnectProvider = useCallback(async () => {
1819
if (walletConnectProvider) return Promise.resolve(walletConnectProvider);
1920

@@ -30,6 +31,7 @@ export const useWalletConnectProvider = (walletConnect?: UniversalProviderOpts)
3031
setMounted(true);
3132

3233
import('@walletconnect/universal-provider').then(async ({ UniversalProvider }) => {
34+
/* v8 ignore next 7 */
3335
const provider = await UniversalProvider.init(walletConnect);
3436

3537
setWalletConnectProvider(provider);

packages/solana/src/wallet-connect-adapter.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
import type { WalletName } from '@solana/wallet-adapter-base';
23
import {
34
BaseSignerWalletAdapter,

packages/solana/src/wallets/built-in.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
import {
23
metadata_Backpack,
34
metadata_CoinbaseWallet,

packages/solana/src/wallets/factory.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
import type {
23
StandardWalletFactoryBuilder,
34
WalletConnectWalletFactoryBuilder,

packages/wagmi/src/utils.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
import debug from 'debug';
21
import type { Connector as WagmiConnector } from 'wagmi';
32
import { injected } from 'wagmi/connectors';
43

5-
const createDebug = (namespace: string) => {
6-
return debug(`antd-web3:wagmi:${namespace}`);
7-
};
8-
94
const isEIP6963Connector = (connector: WagmiConnector) => {
105
if (connector.type === injected.type && connector.icon && connector.id && connector.name) {
116
return true;
127
}
138
return false;
149
};
1510

16-
export { createDebug, isEIP6963Connector };
11+
export { isEIP6963Connector };

packages/wagmi/src/wallets/safeheron.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
import { metadata_Safeheron } from '@ant-design/web3-assets';
23
import { type Wallet } from '@ant-design/web3-common';
34
import type { Connector } from 'wagmi';

packages/web3/src/connect-modal/__tests__/mock/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
import type { DefaultGuide } from '@ant-design/web3';
23

34
export const walletList = [

packages/web3/src/connect-modal/context/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
import React from 'react';
23
import type { ConnectOptions } from '@ant-design/web3-common';
34
import { defaultLocale } from '@ant-design/web3-common';

packages/web3/src/pay-panel/PayPanelContext.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* v8 ignore start */
12
import React from 'react';
23
import { type Chain, type Token, type WalletMetadata } from '@ant-design/web3-common';
34

packages/web3/src/utils/format.ts

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const formatAddress = (address: string = '', groupSize = 4): string => {
3737
const formattedGroups = [];
3838

3939
const has0x = address.startsWith('0x');
40+
/* v8 ignore next */
4041
const formatText = has0x ? address.slice(2) : address;
4142

4243
for (let i = 0; i < formatText.length; i += groupSize) {
@@ -46,6 +47,7 @@ export const formatAddress = (address: string = '', groupSize = 4): string => {
4647

4748
const formattedText = formattedGroups.join(' ');
4849

50+
/* v8 ignore next */
4951
return has0x ? `0x ${formattedText}` : formattedText;
5052
};
5153

packages/web3/src/utils/tool.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ export const isDarkTheme = (token: GlobalToken) => {
77
};
88

99
export const formatNumUnit = (num: number) => {
10+
/* v8 ignore next */
1011
return num > 1000 ? `${(num / 1000).toFixed(1)}k` : num;
1112
};

vitest.config.mts

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export default defineConfig({
6060
setupFiles: ['./tests/setup.ts'],
6161
reporters: ['default'],
6262
coverage: {
63-
include: ['packages/*/src/**/*.{tx,tsx}'],
64-
exclude: ['**/demos/*.tsx'],
63+
include: ['packages/*/src/**/*.{ts,tsx}'],
64+
exclude: ['**/demos/*.{ts,tsx}', '**/src/index.ts'],
6565
reporter: ['json-summary', ['text', { skipFull: true }], 'cobertura', 'html'],
6666
},
6767
testTimeout: 3e4,

0 commit comments

Comments
 (0)