
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
jest-webextension-mock
Advanced tools
For npm:
npm i --save-dev jest-webextension-mock
For yarn:
yarn add --dev jest-webextension-mock
In your package.json
under the jest
section add the setupFiles
attribute with this module name.
"jest": {
"setupFiles": [
"jest-webextension-mock"
]
}
Alternatively you can create a new setup file and require this module.
__setups__/chrome.js
require('jest-webextension-mock');
And add that file to your setupFiles
:
"jest": {
"setupFiles": [
"./__setups__/chrome.js"
]
}
Use this module to check that API calls were made when expected.
describe('your function to test', () => {
it('should have called a webextension API', () => {
yourFunctionToTest();
expect(chrome.tabs.update).toHaveBeenCalled();
});
});
Check the API was called with certain parameters.
describe('your function to test', () => {
it('should have called a webextension API', () => {
yourFunctionToTest();
expect(chrome.tabs.update).toHaveBeenCalledWith({
url: 'https://example.com/'
});
});
});
And you can reset the API mocks to ensure APIs are only called when needed.
beforeEach(() => {
browser.geckoProfiler.start.mockClear();
browser.geckoProfiler.stop.mockClear();
});
it('should toggle the profiler on from stopped', () => {
const store = mockStore(reducer(undefined, {}));
const expectedActions = [
{ type: 'PROFILER_START', status: 'start' },
{ type: 'PROFILER_START', status: 'done' },
];
return store.dispatch(actions.toggle()).then(() => {
expect(browser.geckoProfiler.start).toHaveBeenCalledTimes(1);
expect(store.getActions()).toEqual(expectedActions);
});
});
npm install
npm test
4.0.0
FAQs
Mock the components of a WebExtension
The npm package jest-webextension-mock receives a total of 16,474 weekly downloads. As such, jest-webextension-mock popularity was classified as popular.
We found that jest-webextension-mock demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.