This document provides guidance for running and developing end-to-end (E2E) tests for Pinecone Explorer using Playwright.
The E2E testing infrastructure uses Playwright for Electron app automation.
Note: E2E tests run locally only. Electron cannot run in CI sandbox environments like GitHub Actions.
Tests create database connection profiles programmatically via the window.electronAPI exposed by the preload script. This approach:
- Tests the actual IPC communication path users take
- Avoids modifying production code for test purposes
- Validates the full integration flow
- Node.js 22+
- pnpm 9+
# Run all tests
pnpm run test:e2e
# Run with UI mode (interactive)
pnpm run test:e2e:ui
# Run with debugger
pnpm run test:e2e:debugAfter tests complete:
pnpm exec playwright show-report| Script | Description |
|---|---|
test:build |
Build Electron app for testing |
test:e2e |
Build and run E2E tests |
test:e2e:ui |
Run tests in interactive UI mode |
test:e2e:debug |
Run tests with debugger |
pinecone-explorer/
├── e2e/
│ ├── electron.setup.ts # Electron launcher and profile utilities
│ └── example.spec.ts # Example test suite
└── playwright.config.ts # Playwright configuration
import { test, expect } from '@playwright/test'
import {
launchElectronApp,
closeElectronApp,
cleanupTestProfiles,
createPineconeTestProfile,
connectToProfile,
type ElectronTestContext,
} from './electron.setup'
let electronContext: ElectronTestContext
test.beforeAll(async () => {
electronContext = await launchElectronApp()
})
test.afterAll(async () => {
await cleanupTestProfiles(electronContext.page)
await closeElectronApp(electronContext.app)
})
test('should create Pinecone profile', async () => {
const { page } = electronContext
// Create profile programmatically
const profileId = await createPineconeTestProfile(page)
// Connect to profile
await connectToProfile(page, profileId)
// Use electronAPI to interact with the database
const indexes = await page.evaluate(async (id) => {
return await (window as any).electronAPI.pinecone.listIndexes(id)
}, profileId)
expect(Array.isArray(indexes)).toBe(true)
})Launches the Electron app with test environment variables.
Creates a Pinecone profile and returns the profile ID.
Connects to a profile via IPC.
Deletes all test profiles (IDs starting with 'test-').
Gracefully closes the Electron app.
Each test should:
- Create its own unique profile using timestamp-based IDs
- Clean up indexes/data created during the test
- Use the
afterAllhook to delete test profiles
The following environment variables are automatically set during tests:
NODE_ENV=test
DISABLE_ANALYTICS=trueProblem: Tests fail with "Could not find Electron app"
Solution:
# Ensure the app is built
pnpm run test:build
# Verify main.js exists
ls -la dist-electron/main.jsProblem: Tests fail with "electronAPI is not defined"
Solution:
- Verify the preload script is loaded
- Check that
window.electronAPIis exposed - Enable debug mode:
DEBUG=pw:api pnpm run test:e2e:debug
Problem: Tests hang or timeout after 60 seconds
Solutions:
- Check if the app is launching properly
- Increase timeout in
playwright.config.tsif needed - Run in headed mode to see what's happening:
pnpm run test:e2e:debug
Since Pinecone requires a cloud connection, testing against real Pinecone requires:
-
Set the
PINECONE_API_KEYenvironment variable:PINECONE_API_KEY=your-key-here pnpm run test:e2e
-
Use the free tier for testing (avoid costs)
-
Consider skipping Pinecone API tests in local development:
test.skip(!process.env.PINECONE_API_KEY, 'should work with Pinecone', async () => { // Pinecone test })
- Always build before testing: The
test:e2escript does this automatically - Use unique IDs: All test profiles use timestamp-based IDs to avoid conflicts
- Clean up resources: Delete test indexes and profiles in
afterAllhooks - Serial execution: Tests run serially (workers: 1) to avoid conflicts
- Capture artifacts: Screenshots, videos, and traces are captured on failure
- Build time: ~10-15 seconds
- Test execution: ~5-10 seconds per test
- Total workflow: ~30 seconds - 1 minute
- Add visual regression testing
- Add performance benchmarks
- Test more complex workflows (multi-step operations)
- Add accessibility testing
- Test offline/error scenarios
- Investigate CI options for Electron testing (self-hosted runners, etc.)