npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pwtap/plugin-db

v1.1.2

Published

Database testing for Playwright — a raw Knex instance (Postgres/MySQL/MariaDB/SQLite) and a raw MongoDB Db, with seed/reset and migration verification

Readme

@pwtap/plugin-db

Database testing for the Playwright Test Automation Platform — query assertions, seed/reset, and migration verification, across PostgreSQL, MySQL, MariaDB and SQLite (through Knex) plus MongoDB.

npm

| Fixture | You get | Engines | | ------- | ------------------- | ---------------------------------- | | sql | a raw Knex instance | PostgreSQL, MySQL, MariaDB, SQLite | | mongo | a raw MongoDB Db | MongoDB |

No wrapper and no unified "database" API: you already know these clients, and a common layer over a relational and a document model would leak in exactly the places you need precision.

1. Install

npx @pwtap/create add db

Then the driver for the one engine you run — they are optional peers, so you install none you don't need:

| Your database | DB_CLIENT | Install | | ------------- | ---------------- | ------------------------- | | PostgreSQL | pg | npm i -D pg | | MySQL | mysql | npm i -D mysql2 | | MariaDB | mariadb | npm i -D mysql2 | | SQLite | better-sqlite3 | npm i -D better-sqlite3 | | MongoDB | — | ships installed |

2. Configure

In env/environments.json — not in your test files:

{
  "common": {
    "DB_CLIENT": "pg",
    "DB_CONNECTION_STRING": "postgresql://app:secret@localhost:5432/app_test",
    "MONGO_CONNECTION_STRING": "mongodb://localhost:27017",
    "MONGO_DATABASE": "app_test"
  }
}

The fixtures read those keys themselves, so no test.use({ db }) is needed. Set the option only to override one file — test.use({ db: { client: 'better-sqlite3', connection: { filename: ':memory:' } } }) — and it wins, with anything it leaves out still coming from the env.

3. Write

These fixtures belong inside your API and UI tests, because the usual question is the one after an action: did the right row appear?

import { expect, test } from '@fixtures';

test('posting an order writes the row', async ({ request, sql }) => {
  await request.post('/orders', { data: { sku: 'ABC-1' } });

  const order = await sql('orders').where({ sku: 'ABC-1' }).first();
  expect(order).toBeTruthy();
  expect(order.status).toBe('pending');
});

4. Run

npx playwright test              # ordinary tests, no separate project
npx playwright test e2e/db       # just the DB-only specs

A database that is unreachable or unconfigured skips the test with the reason rather than failing it, the same way an absent device does — and the reason is printed next to the skip, not only buried in a report:

↷ skipped — [db] the pg driver is not installed — run `npm i -D pg`

Full guide

docs/DB_TESTING.md walks the whole path in order: driver, configuration, writing, running, worker-scope rules, keeping tests independent under parallelism, migrations and seeds for both engines, what each reporter records, and a table of every skip message with what to do about it.

License

MIT