Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(testing): Stub chrome and browser globals with fakeBrowser automatically #925

Merged
merged 1 commit into from
Aug 18, 2024

Conversation

aklinker1
Copy link
Collaborator

@aklinker1 aklinker1 commented Aug 18, 2024

Apart of #868. If you're using Vitest, the following code is now ran automatically in a setup file:

import { vi } from 'vitest';
import { fakeBrowser } from 'wxt/testing';
vi.stubGlobal("chrome", fakeBrowser);
vi.stubGlobal("browser", fakeBrowser);

This allows you to use packages that depend on these globals in your tests with zero config.

Copy link

netlify bot commented Aug 18, 2024

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 4570d23
🔍 Latest deploy log https://app.netlify.com/sites/creative-fairy-df92c4/deploys/66c2513094c9220008b4e328
😎 Deploy Preview https://deploy-preview-925--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@aklinker1 aklinker1 marked this pull request as ready for review August 18, 2024 19:56
@aklinker1 aklinker1 merged commit 067b2ec into main Aug 18, 2024
14 checks passed
@aklinker1 aklinker1 deleted the test-setup-globals branch August 18, 2024 19:56
Copy link

codecov bot commented Aug 19, 2024

Codecov Report

Attention: Patch coverage is 8.33333% with 11 lines in your changes missing coverage. Please review.

Project coverage is 82.24%. Comparing base (2e1bd6e) to head (4570d23).
Report is 5 commits behind head on main.

Files Patch % Lines
...src/core/builders/vite/plugins/extensionApiMock.ts 8.33% 11 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #925   +/-   ##
=======================================
  Coverage   82.24%   82.24%           
=======================================
  Files         125      125           
  Lines        6568     6580   +12     
  Branches     1095     1098    +3     
=======================================
+ Hits         5402     5412   +10     
- Misses       1152     1154    +2     
  Partials       14       14           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it 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