Skip to content

Another mock library for Chrome Extensions API

License

Notifications You must be signed in to change notification settings

ueokande/mock-chrome

Repository files navigation

mock-chrome

Note

This library is still under experimental development. Please keep in mind that the API may change in the future.

The mock-chrome is an another mock library for Chrome Extensions API. This library has the following features:

  • TypeScript support
  • Manifest V3 support
  • No dependencies on testing libraries

Installation

npm install --save-dev mock-chrome

Usage

The library provides two types of mocks.

newToDoApi()

The newToDoApi() creates a mocked Chrome API object that always throw an error when it is called. It is useful when you want to mock by yourself using test frameworks like Jest or Vitest.

import { newToDoApi } from 'mock-chrome';

global.chrome = newToDoApi();

newMockApi()

The newMockApi() creates a mocked Chrome API object that provides a fake implementation of the Chrome API.

import { newMockApi } from 'mock-chrome';

global.chrome = newMockApi();

License

MIT