Skip to content

Expose Pinia Colada devtools actions via headless API for E2E testing #437

@JessicaSachs

Description

@JessicaSachs

Problem

In browser-driven E2E tests (Playwright, Cypress), I want a deterministic way to test UI states that are driven by async data fetching (loading, error, success). In Nuxt SSR applications, this is difficult to achieve reliably using network interception alone, since initial data is often hydrated from the SSR payload and may not trigger client-side requests.

Pinia Colada devtools already provide excellent controls for forcing these query states during development, but those controls are currently only accessible via the devtools UI. For E2E testing, interacting with the devtools UI directly is brittle and obscures test intent.

Feature request

Expose an opt-in, programmatic API that mirrors the existing Pinia Colada devtools actions and can be invoked headlessly from browser E2E tests.

Motivation

  • Enables deterministic E2E testing of loading/error UI states
  • Avoids reliance on network timing or interception, especially in SSR contexts
  • Aligns E2E testing with existing developer workflows using Colada devtools
  • Removes the need to automate clicks in the devtools UI

Conceptual API (illustrative)

// Mirrors the devtools UI actions
// API shape and exposure mechanism are open for discussion
coladaDevtools.actions.simulateLoading(['organizations'])
coladaDevtools.actions.simulateError(['organizations'])
coladaDevtools.actions.reset(['organizations'])
coladaDevtools.actions.invalidate(['organizations'])
coladaDevtools.actions.refetch(['organizations'])

Exposure

If <PiniaColadaDevtools> are enabled, globalThis should be decorated with the global namespace.

Open Questions

  1. What do you think?
  2. What's a good namespace?

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    🆕 Triaging

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions