:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
/**
* Workspace-based Playwright test base with PostHog workspace setup capabilities
*
* This provides clean test fixtures for creating PostHog workspaces
* (organizations, projects, teams) before running tests.
*
* This does NOT auto-login — you get full control over authentication with
* workspace-specific users by calling playwrightSetup.login() explicitly.
*/
/* eslint-disable react-hooks/rules-of-hooks */
import { PlaywrightSetup, PlaywrightWorkspaceSetupResult, createPlaywrightSetup } from './playwright-setup'
import { test as coreTest } from './playwright-test-core'
/**
* Base test with workspace setup capabilities
* Use this for most tests where you want to manually create workspaces
*/
export const test = coreTest.extend<{ playwrightSetup: PlaywrightSetup; workspaceSetup: PlaywrightSetup }>({
playwrightSetup: async ({ baseURL }, use) => {
const playwrightSetup = createPlaywrightSetup(baseURL)
await use(playwrightSetup)
await playwrightSetup.dispose()
},
})
/**
* Test with a pre-created PostHog workspace
* Use this when you want a workspace automatically created before your test runs
*
* The workspace includes: Organization → Project → Team + [email protected] user
*/
export const testWithWorkspace = test.extend<{ workspace: PlaywrightWorkspaceSetupResult }>({
workspace: async ({ playwrightSetup }, use) => {
const workspace = await playwrightSetup.createWorkspace()
await use(workspace)
},
})
// Re-export everything from the core test
export { expect } from './playwright-test-core'
// Re-export playwright setup utilities
export { createPlaywrightSetup, createTestWorkspace } from './playwright-setup'
export type { PlaywrightWorkspaceSetupResult, PlaywrightSetupOptions } from './playwright-setup'