Playwright e2e

From forcedotcom/salesforcedx-vscode · View interactive version

Playwright e2e is an AI agent skill from the GitHub repository forcedotcom/salesforcedx-vscode. writing, running, and debugging Playwright tests; creating and recreating scratch orgs (Dreamhouse, minimal, non-tracking); working with their output from github actions

How to use this skill

Skill file

Playwright E2E Tests

Guidelines for writing and iterating on Playwright tests for VS Code extensions.

Required Reading

Read ALL before responding:

Use playwright-vscode-ext

Shared code (helpers, locators, configuration) for tests.

Desktop workspace shapes (pick one per test):

VSIX mode (useVsix option):

Code Builder container mode (createContainerConfig, createContainerTest):

Span files (when debugging traces)

Available local + CI/GHA.

See .claude/skills/span-file-export/SKILL.md for enable/OTLP vs file.

Telemetry inspection (diagnostic tests)

Desktop tests can inspect both telemetry pipelines on-disk for diagnostic/integration testing:

  1. O11y spans — produced by services Effect pipeline; written to ~/.sf/vscode-spans/*.jsonl (auto-enabled)
  2. AppInsights events — produced by class-based TelemetryFile reporter when localTelemetryLogging is enabled; written to {workspace}/salesforcedx-vscode-core-telemetry.json (AppInsights shape, real client inert in dev/test)

Fixture setup: Enable both pipelines by passing additionalExtensionDirs: ['salesforcedx-vscode-core'] (for core extension + TelemetryFile reporter) and userSettings: { 'telemetry.telemetryLevel': 'all', 'salesforcedx-vscode-core.advanced.localTelemetryLogging': 'true' } to createDesktopTest. Launch against a real scratch org (e.g., orgAlias: MINIMAL_ORG_ALIAS) so org-identity attributes populate in both pipelines.

Reading artifacts:

Pattern: Run command, capture artifacts, reload window to flush TelemetryFile buffer (fires deactivationEvent), then assert event/span presence + attributes. See packages/salesforcedx-vscode-lightning/test/playwright/specs/telemetryOutput.desktop.spec.ts for example.

Checking for Scratch Orgs

If you aren't sure if orgs are set up locally,

sf org list

Look for the required org aliases (e.g., minimalTestOrg, nonTrackingTestOrg, dreamhouseTestOrg). If missing, create them using the appropriate setup commands from references/local-setup.md.

Pro tip: Use sf org list --json | jq '.result.scratchOrgs[] | select(.alias) | .alias' to list only scratch org aliases.

Running tests (AI behavior)

When running Playwright tests (pnpm … test:web, test:desktop, etc.), never block >30s. Use is_background: true so tests run while the AI continues. Check terminal output or output_file later.

Apex OAS E2E Tests

Playwright desktop tests live in packages/salesforcedx-vscode-apex-oas/test/playwright/specs/ with dedicated CI workflow .github/workflows/apexOasE2E.yml (macOS + ubuntu, desktop only). Specs share one MINIMAL_ORG_ALIAS scratch org and are serialized via workers: 1 in playwright.config.desktop.ts. Tests that deploy ESR metadata requiring API >=66 call setWorkspaceApiVersion() to bump the fixture's default sourceApiVersion (64.0 → 66.0). Specs that click modal-dialog buttons require window.dialogStyle: custom in the fixture's userSettings. The OAS REST generation path requires an LLM service registered with the VS Code service provider — supplied at runtime by A4V (salesforce.salesforcedx-einstein-gpt), which is no longer a declared extensionDependency. The AuraEnabled path needs only an active org. Specs exercising REST generation install A4V via the desktop fixture's pre-launch step; obtaining the LLM service is fail-fast, so waitForA4VAndOasCommands calls waitForExtensionsActivated to ensure the provider has registered its command before generation runs.

A4V LLM rate limit = skip, not fail (pre-migration): the shared Core model exhausting its monthly quota is an infra outage, not a product bug — it can hit any spec that triggers a generation LLM call (all composed/decomposed/context-menu specs), not just manual-merge. The extension surfaces it as a real error notification (/monthly rate limit/, from the llm_monthly_rate_limit i18n message) instead of the old generic "LLM did not return any content", so specs detect it straight from the UI — no span-file scan. Wrap the generation success signal with assertGenerationOrSkipOnRateLimit(test, page, success) (oasHelpers): success is the success assertion (expect(tab).toBeVisible() or waitForEsrFile(...)); it races the rate-limit notification and test.skips if that wins, else resolves/rethrows. The eligibility-failure specs (ineligibleClass, mixedFrameworksClass, restResourceNoHttpMethod) fail before any LLM call and need no guard.

Don't use the clipboard to set editor content

navigator.clipboard.writeText + Paste is a shared global resource — desktop Electron clipboard is the system OS clipboard (electronjs.org/docs/latest/api/clipboard), so parallel workers (fullyParallel: true) race: worker B's write between A's write and A's Paste makes A paste B's text. Flaky, hard to diagnose.

Set content directly instead:

Note: "keyboard shortcut can miss on web" comments refer to shortcut keystrokes (Cmd+A/Cmd+V) not landing — fix is command-palette Select All/Paste, not clipboard. Clipboard ≠ required for that.

Running Full E2E Test Suite

See references/full-suite-execution.md for complete guide on running web/desktop E2E tests locally across all packages in dependency order + running container specs.

Container Specs

15 packages ship container Playwright specs (apex, apex-debugger, apex-log, apex-oas, apex-replay-debugger, apex-testing, core, lightning, lwc, metadata, org, org-browser, services, soql, visualforce) — 110 specs total. See the coverage ledger for the per-package list and which specs are intentionally not ported.

Run locally:

npm run test:container:local

(from repo root; pulls image, builds + swaps extensions in, runs all packages' container specs sequentially against 1 shared workbench — flags: --image-tag TAG, --image REF (ECR/Falcon), --run-id ID / --release-tag TAG (VSIX source), --no-teardown, --keep-org, --debug; see references/full-suite-execution.md for details)

Run 1 package:

npm run test:container -w <package>

(assumes container already running; typically invoked by orchestrator, not manually)

See docs/codeBuilderContainerParity.md for coverage ledger (which packages have container specs + rationale).

Orchestrator: scripts/codeBuilderLocalE2E.ts discovers all packages with test:container scripts, spins up 1 container, swaps every built extension into it, runs all suites sequentially. Adding a container suite to a package auto-discovers it (no script edit needed).

Run in CI (full 15-package matrix, not wired per-PR): see references/running-codebuilder-e2e-in-ci.md for dispatching codeBuilderE2E.yml — finding a compatible runId, testing a specific branch/commit/release candidate, checking results, and known gotchas.

Disable/reenable other E2E when iterating

To run only your new test in CI while iterating:

  1. Disable other workflows — add your branch to branches-ignore in .github/workflows/*.yml that have push: branches-ignore: [main, develop] (e.g. testCommitExceptMain.yml, coreE2E.yml, orgBrowserE2E.yml, lwcPlaywrightE2E.yml, etc.)
  2. Filter target workflow — add --grep "Your Test Title" to the test run command in the workflow you care about
  3. Optional — skip org setup steps not needed for your test (e.g. minimal/non-tracking orgs)
  4. Restore — remove branch from branches-ignore, remove --grep, uncomment skipped steps

Test Controller Native Surfaces

When testing native Test Controller surfaces (Test Explorer, Test Results panel):

Reliable Assertions for Async Operations

For desktop-only tests, prefer durable success signals over flaky UI assertions:

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.