Skip to content

feat: add tests#2445

Open
hieu-w wants to merge 3 commits intomasterfrom
feat/add-tests
Open

feat: add tests#2445
hieu-w wants to merge 3 commits intomasterfrom
feat/add-tests

Conversation

@hieu-w
Copy link
Copy Markdown
Member

@hieu-w hieu-w commented Apr 7, 2026

Jira Link

Description

Adds browser-based Vitest suites (Playwright: Chromium, Firefox, WebKit) for @web3auth/no-modal and @web3auth/modal, with tests living under each package’s test/ folder.

  • Vitest config (test/configs/browsers.config.mts): loadEnv("test", <packageRoot>, "VITE_") plus define for process.env.VITE_APP_INFURA_PROJECT_KEY so dependencies that read Infura env at load time work in the browser.
  • Setup (test/setup/browser-polyfills.ts): ensures globalThis.process exists so SDK / dependency code that touches process.env (e.g. WEB3AUTH_VERSION) does not throw in the browser runner.
  • Coverage: Istanbul against each package’s src/**/*.{ts,tsx} as appropriate.
  • Modal: server.fs.allow for the monorepo root (hoisted node_modules) and optimizeDeps.include for React/UI-related deps to avoid mid-run Vite reloads and flaky dynamic imports in browser mode.
  • ESLint: relax import/no-extraneous-dependencies for packages/**/test/**; modal package eslint targets ./test/configs/browsers.config.mts for devDependency resolution.
  • .env.test.example in each package documents optional VITE_APP_INFURA_PROJECT_KEY for local .env.test.

no-modal tests cover Web3AuthNoModal, BaseConnector, and shared helpers/mocks. Modal tests cover Web3Auth (modal manager) and LoginModal UI (mount/open).

How has this been tested?

  • cd packages/no-modal && npm test — Vitest browser run (3 browsers) with coverage; all tests passing.
  • cd packages/modal && npm test — same; all tests passing.
  • Root: npm test (Lerna parallel test in workspaces) should run both package test scripts.

Screenshots (if appropriate)

N/A — test and tooling changes only; no end-user UI product changes.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • My code follows the code style of this project. (run lint)
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (.env.test.example per package; no separate doc site update.)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Note

Medium Risk
Mostly adds test infrastructure and new browser-run test suites, but it also changes how tests are executed (removes node configs / per-package scripts) and introduces a new dependency plus a large package-lock.json churn that could affect CI installs.

Overview
Adds browser-based Vitest (Playwright) test coverage for @web3auth/no-modal and @web3auth/modal, including new test/ helpers/mocks and suites that exercise key connector/Web3Auth flows plus a basic LoginModal UI mount/open check.

Updates Vitest browser configs to load VITE_ env via Vite, inject VITE_APP_INFURA_PROJECT_KEY, allow monorepo-root FS access, and (for modal) pre-bundle heavy UI deps to reduce flakiness; coverage reporting is expanded and test-only files are excluded.

Aligns tooling around the new test layout by relaxing ESLint’s import/no-extraneous-dependencies for packages/**/test/**, simplifying root and package test scripts to run the browser config, adding .env.test.example files, and updating dependencies/lockfile (including adding ox).

Reviewed by Cursor Bugbot for commit 8cc7bc4. Bugbot is set up for automated code reviews on this repo. Configure here.

@hieu-w hieu-w requested review from a team as code owners April 7, 2026 07:51
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web3auth-web Ready Ready Preview, Comment Apr 7, 2026 8:27am

Request Review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit bb9c2f4. Configure here.

"test": "cross-env FORCE_COLOR=1 lerna run test --parallel",
"test:node": "cross-env FORCE_COLOR=1 lerna run test:node --parallel",
"test:browsers": "cross-env FORCE_COLOR=1 lerna run test:browsers --parallel",
"test-debugger": "cross-env FORCE_COLOR=1 lerna run test-debugger --parallel"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React override version conflicts with lockfile resolution

Medium Severity

The root overrides pin react and react-dom to "19.2.0", but the updated package-lock.json now resolves both to 19.2.4 (with the "peer" flag removed). This mismatch was introduced by this PR's lockfile changes, likely a side effect of adding vitest as a production dependency which altered how npm resolves the dependency tree. The override is no longer being honored.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bb9c2f4. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant