A powerful and type-safe library for interacting with IndexedDB in Playwright tests.
- 🎭 Seamless integration with Playwright
- 📦 Full TypeScript support
- 🔄 Complete CRUD operations
- 🧪 Comprehensive test coverage
- 🚀 Promise-based API
- 💪 Type-safe operations
npm install playwright-indexeddb
import { test } from "@playwright/test";
import { PlaywrightIndexedDB } from "playwright-indexeddb";
test("example test", async ({ page }) => {
// Initialize IndexedDB
const db = new PlaywrightIndexedDB(page, {
dbName: "myDatabase",
storeName: "myStore",
version: 1, // optional, defaults to 1
});
// Put an item
await db.putItem({ id: 1, name: "Test Item" }, 1);
// Get an item
const item = await db.getItem(1);
// Get all items
const allItems = await db.getAllItems();
// Delete an item
await db.deleteItem(1);
// Clear all items
await db.clear();
});
new PlaywrightIndexedDB(page: Page, options: IndexedDBOptions)
dbName
: string - Name of the IndexedDB databasestoreName
: string - Name of the object storeversion?
: number - Database version (optional, defaults to 1)
Returns all items from the store as an array of type T.
Returns a single item of type T for the given key, or null if not found.
Stores an item in the database. If key is provided, it will be used as the item's key.
Deletes the item with the specified key.
Removes all items from the store.
# Install dependencies
npm install
# Run tests
npm test
# Run linter
npm run lint
# Build package
npm run build
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
MIT
If you find any bugs or have feature requests, please create an issue in the GitHub repository.