Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 2, 2025

This PR adds a complete Playwright testing setup to the dev/preact application, providing end-to-end test coverage for the Preact-based development environment.

What's Added

Testing Infrastructure

  • Playwright configuration (playwright.config.ts) with automatic dev server integration
  • Test directory structure (tests/e2e/) separate from unit tests
  • Browser setup using Playwright's managed browsers (automatic installation)
  • NPM scripts for running e2e tests (test:e2e, test:e2e:ui)

Test Coverage

A comprehensive home page test that validates:

  • Page loads correctly at the root route (/)
  • Page title matches expected "Vite + Preact" format
  • Critical DOM elements are rendered (app container, main content area)
  • Application-specific content is displayed (welcome message, description text)

Configuration Updates

  • Vitest isolation: Updated vite.config.ts to exclude Playwright tests from vitest runner
  • Dependency management: Added @playwright/test to dev dependencies
  • Test separation: Unit tests (vitest) and e2e tests (Playwright) run independently
  • Git exclusions: Added playwright-report/ and test-results/ to .gitignore to prevent generated files from being tracked

Key Features

🚀 Zero-configuration testing: Tests automatically start the dev server, run tests, and clean up
🔧 CI/CD ready: Uses Playwright-managed browsers, works reliably in containerized environments
📊 Rich reporting: HTML test reports with screenshots and traces on failures
🔄 Developer friendly: UI mode available for interactive test development

Usage

# Run end-to-end tests
npm run test:e2e

# Run with interactive UI
npm run test:e2e:ui

# Unit tests continue to work as before
npm test

The setup ensures that both testing frameworks coexist without conflicts, providing comprehensive coverage from unit level to full user workflows. The test validates that the Preact application correctly renders the welcome page with all expected content and interactive elements.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Create a testing setup for the dev/preact app using Playwright. Just setup the boilerplate, add dependencies and write one simple test (open the main page, check that it's rendering something). The test must run in your environment as well, and it must... feat(dev/preact): add Playwright testing setup with e2e test coverage Sep 2, 2025
@@ -0,0 +1,76 @@


<!DOCTYPE html>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Why is this here? The reports should be excluded from git completely. Update .gitignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right! I've removed the Playwright report files from git tracking and updated the .gitignore to exclude /playwright-report/ and /test-results/ directories. These are generated files that should never be committed to version control. Fixed in commit 472cfb9.

@@ -0,0 +1,82 @@
# Playwright Testing Setup for dev/preact
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Drop this entire file. It's useless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the PLAYWRIGHT_SETUP.md file. Fixed in commit 99d9770.

...devices['Desktop Chrome'],
// Use system chromium path
launchOptions: {
executablePath: '/usr/bin/chromium'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Let Playwright install its own browsers, do not rely on the user setup having something available. Chrome may not be installed, or it may be installed at a different path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the Playwright configuration to remove the hardcoded chromium path. Playwright will now install and manage its own browsers automatically, making it work reliably across different environments. Fixed in commit 99d9770.

Copy link
Contributor Author

Copilot AI commented Sep 2, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants