UXP Toolkit
    Preparing search index...
    • Create a Vitest pool that runs tests in a CDP-connected environment.

      This pool communicates with the target runtime (browser, Photoshop UXP, Electron, etc.) using the Chrome DevTools Protocol. Messages are sent via Runtime.evaluate and responses are received via consoleAPICalled events.

      Parameters

      Returns PoolRunnerInitializer

      A PoolRunnerInitializer for Vitest

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

      export default defineConfig({
      test: {
      pool: cdpPool({
      // Static WebSocket URL
      cdpUrl: "ws://localhost:9222/devtools/page/ABC123",
      }),
      },
      });
      // With dynamic URL (e.g., for Photoshop UXP)
      import { setupDevtoolsUrl } from "@bubblydoo/uxp-devtools-common";

      export default defineConfig({
      test: {
      pool: cdpPool({
      cdpUrl: () => setupDevtoolsUrl(pluginPath, pluginId),
      debug: true,
      }),
      },
      });
      // With execution context filter
      export default defineConfig({
      test: {
      pool: cdpPool({
      cdpUrl: "ws://localhost:9222/devtools/page/ABC123",
      executionContextOrSession: async (cdp) => {
      const desc = await waitForExecutionContextCreated(cdp);
      return { uniqueId: desc.uniqueId };
      },
      }),
      },
      });