azure-mock
v2.38.0
Published
A library that contains azure mock classes.
Maintainers
Readme
azure-mock
Mock Azure service classes for local development and testing. Provides in-memory implementations of Azure Table Storage, Blob Storage, Service Bus, and EventGrid clients that mirror the real Azure SDK interfaces.
Table of Contents
🚀 Getting Started
pnpm i -D azure-mock @azure/core-http-compat @azure/core-rest-pipeline @azure/data-tables @azure/eventgrid @azure/service-bus @azure/storage-blob📖 Documentation
We highly recommend you take a look at the documentation to level up.
Available Mocks
| Class | Azure Equivalent | Description |
| ------------------------------ | -------------------------- | -------------------------------------------- |
| MockTableClient | TableClient | In-memory Azure Table Storage |
| MockContainerClient | ContainerClient | In-memory blob container, listing and paging |
| MockBlobClient | BlobClient | In-memory blob read, copy and delete |
| MockBlockBlobClient | BlockBlobClient | In-memory block blob upload and download |
| MockBlobBatchClient | BlobBatchClient | In-memory batched blob deletion |
| MockSearchClient | SearchClient | In-memory Azure AI Search index |
| MockQueueClient | QueueClient | In-memory Azure Storage Queue |
| MockServiceBusSender | ServiceBusSender | In-memory Azure Service Bus |
| MockWebPubSubServiceClient | WebPubSubServiceClient | In-memory Azure Web PubSub |
| MockEventGridPublisherClient | EventGridPublisherClient | In-memory EventGrid publisher |
Each client's state lives in an exported Mock*Database map (MockTableDatabase, MockContainerDatabase, …), so a test resets by clearing the one it seeded.
Usage
import { MockTableClient } from "azure-mock";
const mockTableClient = new MockTableClient("", "tableName");
await mockTableClient.upsertEntity({ partitionKey: "pk", rowKey: "rk", value: 42 });
const entity = await mockTableClient.getEntity("pk", "rk");Replace real Azure clients with their mock equivalents by swapping them in your test setup or local .env configuration.
Commands
Run from packages/azure-mock/:
pnpm build # compile to dist/
pnpm test # vitest watch mode (coverage is run from the repo root)
pnpm lint:fix # auto-fix lint
pnpm typecheck # type check⚖️ License
This project is licensed under the Apache-2.0 license.
