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

@bubblydoo/vitest-pool-cdp

v0.0.3

Published

Custom Vitest pool that runs tests in CDP-connected environments (browsers, Photoshop UXP, Electron, etc.)

Downloads

156

Readme

@bubblydoo/vitest-pool-cdp

Custom Vitest pool that runs tests in CDP-connected environments (browsers, Photoshop UXP, Electron, etc.).

Overview

This package provides a custom Vitest v4+ pool that executes tests in any environment that supports the Chrome DevTools Protocol (CDP). This enables running Vitest tests inside:

  • Browsers (Chrome, Edge, etc.)
  • Adobe Photoshop UXP plugins
  • Electron applications
  • Any other CDP-enabled runtime

Installation

pnpm add -D @bubblydoo/vitest-pool-cdp vitest

Usage

Basic Usage

// vitest.config.ts
import { defineConfig } from "vitest/config";
import { cdpPool } from "@bubblydoo/vitest-pool-cdp";

export default defineConfig({
  test: {
    pool: cdpPool({
      cdpUrl: "ws://localhost:9222/devtools/page/ABC123",
    }),
  },
});

Dynamic URL (e.g., Photoshop UXP)

For environments where the CDP URL is determined at runtime:

// vitest.config.ts
import { defineConfig } from "vitest/config";
import { cdpPool } from "@bubblydoo/vitest-pool-cdp";
import { setupDevtoolsUrl } from "@bubblydoo/uxp-devtools-common";

const pluginPath = "./my-uxp-plugin";
const pluginId = "com.example.myplugin";

export default defineConfig({
  test: {
    pool: cdpPool({
      cdpUrl: () => setupDevtoolsUrl(pluginPath, pluginId),
      debug: true,
    }),
  },
});

With Execution Context Filter

If the CDP target has multiple execution contexts, you can filter to select a specific one:

export default defineConfig({
  test: {
    pool: cdpPool({
      cdpUrl: "ws://localhost:9222/devtools/page/ABC123",
      contextFilter: (context) => context.origin.includes("my-app"),
    }),
  },
});

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | cdpUrl | string \| () => Promise<string> | required | WebSocket URL for CDP connection, or async function returning one | | contextFilter | (context: ExecutionContextDescription) => boolean | undefined | Filter function to select a specific execution context | | debug | boolean | false | Enable debug logging | | connectionTimeout | number | 30000 | Timeout in milliseconds for establishing the CDP connection |

How It Works

┌─────────────────────┐                    ┌─────────────────────┐
│   Vitest (Node.js)  │                    │   CDP Target        │
│                     │                    │   (Browser/UXP/etc) │
├─────────────────────┤                    ├─────────────────────┤
│   CdpPoolWorker     │                    │   Worker Runtime    │
│                     │                    │   (injected)        │
│   ┌─────────────┐   │   CDP WebSocket    │   ┌─────────────┐   │
│   │ send()      │───┼──Runtime.evaluate──┼──►│ receive()   │   │
│   └─────────────┘   │                    │   └─────────────┘   │
│                     │                    │                     │
│   ┌─────────────┐   │  consoleAPICalled  │   ┌─────────────┐   │
│   │ on('msg')   │◄──┼────────────────────┼───│ post()      │   │
│   └─────────────┘   │                    │   └─────────────┘   │
└─────────────────────┘                    └─────────────────────┘
  1. Pool to Worker: Messages are sent via Runtime.evaluate() calling a global function
  2. Worker to Pool: Responses are sent via console.debug() with a special prefix, captured by Runtime.consoleAPICalled events
  3. Serialization: Uses devalue for structured cloneable data (same as Vitest internally)

Requirements

  • Vitest v4 or later
  • A CDP-enabled target environment
  • The target environment must support:
    • console.debug() for sending messages
    • Global function assignment for receiving messages

Limitations

  • Tests run in a single CDP execution context (no parallel test isolation within the same context)
  • The target environment must have a JavaScript runtime that supports ES2022+
  • Some Vitest features that rely on Node.js-specific APIs may not work in all CDP environments

License

MIT