Skip to content

Commit

Permalink
Merge pull request #198 from AElfProject/chore/add-vitest
Browse files Browse the repository at this point in the history
Chore/add vitest
  • Loading branch information
aelf-lxy authored Nov 26, 2024
2 parents 93d1285 + 08adad7 commit 4756be0
Show file tree
Hide file tree
Showing 22 changed files with 653 additions and 1,010 deletions.
1 change: 0 additions & 1 deletion .eslintcache

This file was deleted.

4 changes: 2 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "https://biomejs.dev/schemas/1.0.0/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"formatter": {
"enabled": true,
"ignore": ["./dist/*", "./es/**/*", "./lib/**/*", "_site/**/*"],
"indentStyle": "space",
"lineWidth": 100,
"indentSize": 2
"indentWidth": 2
},
"javascript": {
"formatter": {
Expand Down
30 changes: 25 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,33 @@
"lint-staged": {
"*.{ts,tsx,js,jsx}": [
"biome format --write",
"npm run prettier"
"pnpm prettier",
"pnpm eslint"
],
"*.{json,less,md}": "prettier --ignore-unknown --write"
},
"devDependencies": {
"@babel/core": "^7.24.7",
"@babel/parser": "^7.24.0",
"@biomejs/biome": "^1.4.1",
"@babel/preset-env": "^7.24.7",
"@babel/preset-react": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@biomejs/biome": "^1.9.2",
"@changesets/changelog-git": "^0.2.0",
"@changesets/cli": "^2.27.1",
"@happy-dom/jest-environment": "^15.11.6",
"@ianvs/prettier-plugin-sort-imports": "^4.1.1",
"@testing-library/react": "^14.1.2",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@testing-library/react-hooks": "^8.0.1",
"@types/jest": "^29.5.12",
"@types/node": "^22.9.3",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"@vitest/coverage-v8": "^1.1.0",
"@vitest/coverage-v8": "^2.1.5",
"babel-jest": "^29.7.0",
"babel-plugin-transform-remove-console": "^6.9.4",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -67,15 +80,22 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-unused-imports": "^3.0.0",
"father": "^4.3.8",
"happy-dom": "^15.11.6",
"husky": "^8.0.3",
"jest": "^29.7.0",
"jest-canvas-mock": "^2.5.2",
"jest-environment-jsdom": "^29.7.0",
"jest-junit": "^16.0.0",
"jest-transform-stub": "^2.0.0",
"jsdom": "^23.0.1",
"lint-staged": "^15.2.0",
"node-fetch": "^3.3.2",
"prettier": "^3.1.1",
"rimraf": "^5.0.5",
"ts-jest": "^29.2.5",
"typescript": "^5.3.3",
"vitest": "^1.3.1"
"vite-tsconfig-paths": "^5.1.3",
"vitest": "^2.1.5"
},
"ci": {
"type": "aci",
Expand Down
9 changes: 1 addition & 8 deletions packages/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,7 @@
"@babel/preset-env": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@portkey/did-ui-react": "^2.15.9",
"@portkey/types": "^2.15.9",
"@types/jest": "^29.5.12",
"babel-jest": "^29.7.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-junit": "^16.0.0",
"jsdom": "^23.0.1",
"typescript": "^5.3.3"
"@portkey/types": "^2.15.9"
},
"peerDependencies": {
"@portkey/did-ui-react": "^2.15.9"
Expand Down
9 changes: 4 additions & 5 deletions packages/bridge/coverage/coverage-summary.json

Large diffs are not rendered by default.

104 changes: 59 additions & 45 deletions packages/bridge/jest-report.xml
Original file line number Diff line number Diff line change
@@ -1,45 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="jest tests" tests="17" failures="0" errors="0" time="2.076">
<testsuite name="useLockCallback Hook" errors="0" failures="0" skipped="0" timestamp="2024-11-25T10:44:44" time="0.907" tests="4">
<testcase classname="useLockCallback Hook should execute function and lock" name="useLockCallback Hook should execute function and lock" time="0.108">
</testcase>
<testcase classname="useLockCallback Hook should prevent concurrent execution" name="useLockCallback Hook should prevent concurrent execution" time="0.102">
</testcase>
<testcase classname="useLockCallback Hook should allow another execution after previous is finished" name="useLockCallback Hook should allow another execution after previous is finished" time="0.202">
</testcase>
<testcase classname="useLockCallback Hook should release the lock if the callback throws an error" name="useLockCallback Hook should release the lock if the callback throws an error" time="0.006">
</testcase>
</testsuite>
<testsuite name="useMountSignIn" errors="0" failures="0" skipped="0" timestamp="2024-11-25T10:44:45" time="0.298" tests="2">
<testcase classname="useMountSignIn should render the SignInModal and children wrapped in PortkeyProvider" name="useMountSignIn should render the SignInModal and children wrapped in PortkeyProvider" time="0.039">
</testcase>
<testcase classname="useMountSignIn should memoize the rendered component" name="useMountSignIn should memoize the rendered component" time="0.001">
</testcase>
</testsuite>
<testsuite name="getCaContractBase()" errors="0" failures="0" skipped="0" timestamp="2024-11-25T10:44:46" time="0.263" tests="4">
<testcase classname="getCaContractBase() should throw error about chain is not running" name="getCaContractBase() should throw error about chain is not running" time="0.001">
</testcase>
<testcase classname="getCaContractBase() should get back contract base" name="getCaContractBase() should get back contract base" time="0">
</testcase>
<testcase classname="getIsManagerReadOnly() should throw error about chain is not running" name="getIsManagerReadOnly() should throw error about chain is not running" time="0">
</testcase>
<testcase classname="getIsManagerReadOnly() should return false" name="getIsManagerReadOnly() should return false" time="0.004">
</testcase>
</testsuite>
<testsuite name="useVerifier" errors="0" failures="0" skipped="0" timestamp="2024-11-25T10:44:46" time="0.056" tests="7">
<testcase classname="useVerifier should return getRecommendationVerifier and verifySocialToken functions" name="useVerifier should return getRecommendationVerifier and verifySocialToken functions" time="0.001">
</testcase>
<testcase classname="useVerifier should call getRecommendationVerifier with correct chainId" name="useVerifier should call getRecommendationVerifier with correct chainId" time="0.001">
</testcase>
<testcase classname="useVerifier should handle Apple account type correctly" name="useVerifier should handle Apple account type correctly" time="0">
</testcase>
<testcase classname="useVerifier should handle Google account type correctly" name="useVerifier should handle Google account type correctly" time="0.001">
</testcase>
<testcase classname="useVerifier should handle Telegram account type correctly" name="useVerifier should handle Telegram account type correctly" time="0.001">
</testcase>
<testcase classname="useVerifier should throw error for unsupported account type" name="useVerifier should throw error for unsupported account type" time="0.001">
</testcase>
<testcase classname="useVerifier should throw error if verifier is missing" name="useVerifier should throw error if verifier is missing" time="0.003">
</testcase>
</testsuite>
</testsuites>
<?xml version="1.0" encoding="UTF-8" ?>
<testsuites name="vitest tests" tests="17" failures="0" errors="0" time="259.781">
<testsuite name="src/__tests__/mountApp.test.tsx" timestamp="2024-11-25T15:59:45.425Z" hostname="codespaces-005822" tests="2" failures="0" errors="0" skipped="0" time="0.052664635">
<testcase classname="src/__tests__/mountApp.test.tsx" name="useMountSignIn &gt; should render the SignInModal and children wrapped in PortkeyProvider" time="0.041294184">
</testcase>
<testcase classname="src/__tests__/mountApp.test.tsx" name="useMountSignIn &gt; should memoize the rendered component" time="0.009163869">
</testcase>
</testsuite>
<testsuite name="src/__tests__/useLockCallback.test.ts" timestamp="2024-11-25T15:59:45.434Z" hostname="codespaces-005822" tests="4" failures="0" errors="0" skipped="0" time="0.423559953">
<testcase classname="src/__tests__/useLockCallback.test.ts" name="useLockCallback Hook &gt; should execute function and lock" time="0.114030467">
</testcase>
<testcase classname="src/__tests__/useLockCallback.test.ts" name="useLockCallback Hook &gt; should prevent concurrent execution" time="0.101615411">
</testcase>
<testcase classname="src/__tests__/useLockCallback.test.ts" name="useLockCallback Hook &gt; should allow another execution after previous is finished" time="0.202202457">
</testcase>
<testcase classname="src/__tests__/useLockCallback.test.ts" name="useLockCallback Hook &gt; should release the lock if the callback throws an error" time="0.003921104">
</testcase>
</testsuite>
<testsuite name="src/__tests__/useVerifier.test.ts" timestamp="2024-11-25T15:59:45.442Z" hostname="codespaces-005822" tests="7" failures="0" errors="0" skipped="0" time="0.024991089">
<testcase classname="src/__tests__/useVerifier.test.ts" name="useVerifier &gt; should return getRecommendationVerifier and verifySocialToken functions" time="0.01251499">
</testcase>
<testcase classname="src/__tests__/useVerifier.test.ts" name="useVerifier &gt; should call getRecommendationVerifier with correct chainId" time="0.002938669">
</testcase>
<testcase classname="src/__tests__/useVerifier.test.ts" name="useVerifier &gt; should handle Apple account type correctly" time="0.00210914">
</testcase>
<testcase classname="src/__tests__/useVerifier.test.ts" name="useVerifier &gt; should handle Google account type correctly" time="0.001019364">
</testcase>
<testcase classname="src/__tests__/useVerifier.test.ts" name="useVerifier &gt; should handle Telegram account type correctly" time="0.001107559">
</testcase>
<testcase classname="src/__tests__/useVerifier.test.ts" name="useVerifier &gt; should throw error for unsupported account type" time="0.000851991">
</testcase>
<testcase classname="src/__tests__/useVerifier.test.ts" name="useVerifier &gt; should throw error if verifier is missing" time="0.000660174">
</testcase>
</testsuite>
<testsuite name="src/__tests__/utils.test.ts" timestamp="2024-11-25T15:59:45.452Z" hostname="codespaces-005822" tests="4" failures="0" errors="0" skipped="0" time="0.01120921">
<testcase classname="src/__tests__/utils.test.ts" name="getCaContractBase() &gt; should throw error about chain is not running" time="0.00307823">
</testcase>
<testcase classname="src/__tests__/utils.test.ts" name="getCaContractBase() &gt; should get back contract base" time="0.001708872">
</testcase>
<testcase classname="src/__tests__/utils.test.ts" name="getIsManagerReadOnly() &gt; should throw error about chain is not running" time="0.000440193">
</testcase>
<testcase classname="src/__tests__/utils.test.ts" name="getIsManagerReadOnly() &gt; should return false" time="0.004061136">
<system-out>
intg----getIsManagerReadOnly is fail TypeError: caIns.callViewMethod is not a function
at Module.getIsManagerReadOnly [90m(/workspaces/aelf-web-login/packages/bridge/[39msrc/utils.ts:27:28[90m)[39m
at [90m/workspaces/aelf-web-login/packages/bridge/[39msrc/__tests__/utils.test.ts:46:15
at file:///workspaces/aelf-web-login/node_modules/[4m.pnpm[24m/@[email protected]/node_modules/[4m@vitest[24m/runner/dist/index.js:533:5
at runTest (file:///workspaces/aelf-web-login/node_modules/[4m.pnpm[24m/@[email protected]/node_modules/[4m@vitest[24m/runner/dist/index.js:1056:11)
at runSuite (file:///workspaces/aelf-web-login/node_modules/[4m.pnpm[24m/@[email protected]/node_modules/[4m@vitest[24m/runner/dist/index.js:1205:15)
at runSuite (file:///workspaces/aelf-web-login/node_modules/[4m.pnpm[24m/@[email protected]/node_modules/[4m@vitest[24m/runner/dist/index.js:1205:15)
at runFiles (file:///workspaces/aelf-web-login/node_modules/[4m.pnpm[24m/@[email protected]/node_modules/[4m@vitest[24m/runner/dist/index.js:1262:5)
at startTests (file:///workspaces/aelf-web-login/node_modules/[4m.pnpm[24m/@[email protected]/node_modules/[4m@vitest[24m/runner/dist/index.js:1271:3)
at run (file:///workspaces/aelf-web-login/node_modules/[4m.pnpm[24m/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/[4mvitest[24m/dist/workers/runVmTests.js:79:7)
at runVmTests (file:///workspaces/aelf-web-login/node_modules/[4m.pnpm[24m/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/[4mvitest[24m/dist/chunks/vm.Zr4qWzDJ.js:834:5)

</system-out>
</testcase>
</testsuite>
</testsuites>
Loading

0 comments on commit 4756be0

Please sign in to comment.