Comments (5)
Looks like this solution should work vitest-dev/vitest#2667 (comment)
from jest-webextension-mock.
I know, I opened that issue there, 😅 but the point of this issue here would be to avoid having figure out any config for it. It looks like it's as easy as using globalThis.jest ?? globalThis.vi
here. I don't know if that's desirable here though if you don't use vitest anywhere.
from jest-webextension-mock.
I don't know if that's desirable here though if you don't use vitest anywhere.
I don't use vitest so I'm not inclined to attempt to support it here. I wouldn't mind a shim for it but given we'd need some test infra of both systems to make sure it continues to work I think ultimately this would be a pretty big lift for someone to write and then continue to maintain.
from jest-webextension-mock.
@fregante did you manage to mock webextension-polyfill in Vitest tests? If yes could you share how / the public repo that you have? Very much appreciated 🙏🏼
from jest-webextension-mock.
For anyone who comes here wondering how to make this library work with Vitest:
// vitest.setup.ts
import { vi } from "vitest";
//@ts-ignore
globalThis.jest = vi;
// vitest.config.ts
export default defineConfig({
//...
test: {
setupFiles: ["vitest.setup.ts", "jest-webextension-mock"],
sequence: { setupFiles: "list" },
environment: "jsdom"
},
//...
});
I've only been using this for mocking Chrome storage, so I can't speak for the other aspects of web extensions.
from jest-webextension-mock.
Related Issues (20)
- Make runtime.onMessage react to tabs.sendMessage HOT 3
- Add support for browser/chrome.management.* APIs
- Add contribution guidelines
- chrome.storage.local.get should return a deep copy of objects
- Testing onMessage listeners HOT 3
- onMessageExternal missing from from runtime mock HOT 1
- `browser.permissions` is missing HOT 3
- Question: Is webextension-polyfill 0.9.0 supported? HOT 3
- `This script should only be loaded in a browser extension` HOT 1
- Support for manifest version 3 HOT 1
- Missing onChanged on chrome.storage.sync
- Add support for runtime.getManifest HOT 1
- BUG: "Cannot read property 'addListener' of undefined" for `browser.storage.local.onChanged.addListener` HOT 2
- Struggling with ts-jest HOT 2
- chrome.runtime.onMessage inconsistent callback parameters?
- throw new Error('Wrong key given');
- Add support for browser.webRequest API HOT 1
- Add `sidePanel` API
- Separate storage values by type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest-webextension-mock.