| name | author-e2e-tests |
| description | This skill should be used when writing, debugging, or maintaining Playwright e2e tests for Positron. Load this skill when creating new test files, adding test cases, fixing flaky tests, or understanding the test infrastructure. |
Positron Playwright E2E Testing
Purpose
Provides specialized knowledge and patterns for writing correct, reliable Playwright e2e tests that follow Positron's established conventions and avoid common mistakes.
When to Use This Skill
Load this skill when:
- Creating new e2e test files
- Adding test cases to existing test files
- Debugging flaky or failing tests
- Understanding the test fixture system
- Working with page objects
- Choosing correct selectors and assertions
Critical: Test File Structure
Every test file MUST follow this structure:
import { test, expect, tags } from '../_test.setup';
test.use({
suiteId: __filename
});
test.describe('Feature Name', {
tag: [tags.WEB, tags.WIN, tags.CRITICAL, tags.FEATURE_TAG]
}, () => {
test.beforeEach(async function ({ app }) {
});
test.afterEach(async function ({ app, hotKeys }) {
await hotKeys.closeAllEditors();
});
test('Test description', async function ({ app, python }) {
});
});
MANDATORY REQUIREMENTS:
- Import from
../_test.setup - NOT from @playwright/test
- Set
suiteId: __filename - Required for app isolation
- Use
function syntax for tests (not arrow functions) - Required for fixtures
- Add appropriate tags for platform filtering
Quick Reference: Available Fixtures
| Fixture | Use Case |
|---|
app | Access workbench page objects: app.workbench.console, etc. |
page | Direct Playwright page access: page.getByLabel(...) |
python | Auto-start Python interpreter before test |
r | Auto-start R interpreter before test |
sessions | Manual session management: await sessions.start('python') |
executeCode | Execute code: await executeCode('Python', 'print("hi")'); |
openFile | Open file: await openFile('workspaces/test/file.py'); |
hotKeys | Keyboard shortcuts: await hotKeys.closeAllEditors(); |
settings | Change settings: await settings.set({ 'key': value }); |
See references/fixtures.md for complete fixture documentation.
Quick Reference: Page Objects
Access via app.workbench.*:
const { console, variables, dataExplorer, plots, notebooks, sessions } = app.workbench;
await console.executeCode('Python', 'x = 1');
await console.waitForConsoleContents('expected text');
await variables.doubleClickVariableRow('df');
await dataExplorer.grid.verifyTableData([{ col: 'value' }]);
See references/page-objects.md for complete page object documentation.
Quick Reference: Assertions
await expect(locator).toBeVisible({ timeout: 30000 });
await expect(locator).toHaveText('expected');
await expect(locator).toContainText('partial');
await expect(locator).toHaveCount(3, { timeout: 15000 });
await expect(async () => {
await someAction();
await expect(resultLocator).toBeVisible();
}).toPass({ timeout: 15000 });
See references/assertions.md for complete assertion patterns.
Quick Reference: Test Tags
Feature tags (what the test covers):
tags.CONSOLE, tags.DATA_EXPLORER, tags.NOTEBOOKS, tags.PLOTS, tags.VARIABLES
tags.CRITICAL - High priority tests
Platform tags (where the test runs):
tags.WEB - Enable web browser testing
tags.WIN - Enable Windows testing
- Default: Linux/Electron only
test.describe('Console Tests', {
tag: [tags.WEB, tags.WIN, tags.CRITICAL, tags.CONSOLE]
}, () => { ... });
Common Mistakes to Avoid
Critical (will break tests):
- Wrong imports - use
../_test.setup, not @playwright/test
- Missing
suiteId - must have test.use({ suiteId: __filename })
- Arrow functions - use
function syntax, not async ({ app }) =>
- Missing platform tags - add
tags.WEB, tags.WIN for cross-platform
Quality issues:
5. No timeout on assertions - use { timeout: 30000 } for async operations
6. No test.step() - wrap complex multi-action sequences for better reports
See references/common-mistakes.md for 26 detailed gotchas with code examples.
Running Tests
npx playwright test <test-name>.test.ts --project e2e-electron
npx playwright test test/e2e/tests/<category>/
npx playwright test --grep @:critical
npx playwright test --headed
npx playwright test --debug
npx playwright show-report
Progressive Documentation
For detailed information, read the bundled reference docs:
references/test-setup.md - How to configure the local machine environment to run tests
references/test-structure.md - Complete test file structure and organization
references/fixtures.md - All available fixtures and their usage
references/page-objects.md - Page object patterns and available POMs
references/assertions.md - Assertion patterns and waiting strategies
references/common-mistakes.md - Comprehensive list of gotchas to avoid
Key Architecture Principles
- Worker-scoped app - One app instance per test file (suite)
- Test-scoped fixtures -
page, sessions, etc. fresh per test
- Page Object Model - UI interactions wrapped in POMs via
app.workbench.*
- Tag-based filtering - Tests tagged for platform and feature filtering
- Automatic cleanup - Tracing, screenshots attached on failure
Getting Help
- Look at existing tests in
test/e2e/tests/<feature>/ for patterns
- Check page object source in
test/e2e/pages/ for available methods
- Read
test/e2e/tests/_test.setup.ts for fixture definitions
- Use
--debug flag to step through tests interactively