Skip to content

feat(logger): migrate tests to Vitest - #10328

Open
Manvi1203 wants to merge 1 commit into
mainfrom
feature/vitest-logger
Open

feat(logger): migrate tests to Vitest#10328
Manvi1203 wants to merge 1 commit into
mainfrom
feature/vitest-logger

Conversation

@Manvi1203

@Manvi1203 Manvi1203 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Migrates @firebase/logger from legacy Karma + Mocha + Webpack test runner to a unified Vitest multi-project runner (node and browser with Playwright Chromium headless).

Changes

  • Replaced legacy Karma and Mocha runners with unified Vitest runner (vitest.config.mjs)
  • Added packages/logger/test/polyfills.ts and packages/logger/test/setup.ts
  • Added ambient types packages/logger/src/types/vitest-globals.d.ts
  • Added root guard scripts/ensure_playwright.js
  • Deleted deprecated packages/logger/karma.conf.js
  • Kept vitest dependencies scoped to packages/logger/package.json for isolated migration

CI Impact & Verification

  • Test Count: 58 passed across 2 projects (29 Node + 29 Browser Chromium) [no regressions]
  • Before (Karma + Mocha): ~7.8s total (Mocha 1.98s + Karma/Webpack ~5.8s)
  • After (Vitest Unified): 1.42s total execution time

@Manvi1203
Manvi1203 requested a review from a team as a code owner August 25, 2026 23:34
@changeset-bot

changeset-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: fb3ed13

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the testing framework for the logger package from Karma and Mocha to Vitest, introducing new configuration files, setup scripts, and polyfills for both Node.js and browser environments. The feedback highlights several areas for improvement: removing a global 'process.env': {} definition in vitest.config.mjs that breaks Node.js environment variables, using queueMicrotask instead of setTimeout for a more accurate process.nextTick polyfill, applying optional chaining in getTestTitle to prevent potential runtime errors, and removing redundant global type declarations that are already provided by vitest/globals.

Comment thread packages/logger/vitest.config.mjs Outdated
Comment thread packages/logger/test/polyfills.ts Outdated
Comment thread packages/logger/test/setup.ts Outdated
Comment thread packages/logger/src/types/vitest-globals.d.ts Outdated
@Manvi1203
Manvi1203 force-pushed the feature/vitest-logger branch 11 times, most recently from b61cb84 to 3d340c0 Compare August 26, 2026 07:28
@Manvi1203
Manvi1203 force-pushed the feature/vitest-logger branch from 3d340c0 to a57bd88 Compare August 26, 2026 07:29
- Replaced legacy Karma and Mocha runners with unified Vitest multi-project runner
- Added test/polyfills.ts, test/setup.ts, and src/types/vitest-globals.d.ts
- Added scripts/ensure_playwright.js guard to test:all and test:browser
- Deleted deprecated karma.conf.js
- Added resolutions in package.json and updated yarn.lock to preserve CommonJS string-width for CLI tools in Node 22

CI Impact:
• Test Count: 58 passed across 2 projects (29 Node + 29 Browser Chromium) [100% parity, 0 regressions]
• Before (Karma + Mocha): ~7.8s total (Mocha 1.98s + Karma/Webpack ~5.8s)
• After (Vitest Unified):  1.42s total execution time
@Manvi1203
Manvi1203 force-pushed the feature/vitest-logger branch from a57bd88 to fb3ed13 Compare August 26, 2026 08:10
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