Skip to content

feat(playwright): add Playwright integration package#1396

Draft
9aoy wants to merge 22 commits into
mainfrom
9aoy/feat-rstest-playwright
Draft

feat(playwright): add Playwright integration package#1396
9aoy wants to merge 22 commits into
mainfrom
9aoy/feat-rstest-playwright

Conversation

@9aoy

@9aoy 9aoy commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds @rstest/playwright for E2E tests that run in Rstest workers and drive complete pages with Playwright. It provides browser, context, page, request, and static serve fixtures, retrying Playwright-style assertions on top of Rstest expect, headed/debug helpers, and test-local server cleanup. It also exposes the current test file path in task.filepath so extended fixtures can derive per-test cwd when needed.

Examples

Basic usage with a prepared page:

import { expect, test } from '@rstest/playwright';

test('home page', async ({ page, serve }) => {
  const { url } = await serve('./dist/index.html');

  await page.goto(url);
  await expect(page.locator('h1')).toHaveText('Home');
});

Build with Rsbuild first, then open the generated page:

import { expect, test } from '@rstest/playwright';
import { build } from '@rsbuild/core';

test('rsbuild output', async ({ page, serve }) => {
  await build({ cwd: __dirname });

  const { url } = await serve('./dist/index.html');
  await page.goto(url);
  await expect(page).toHaveTitle(/Rsbuild/);
});

Pause for local debugging:

import { test } from '@rstest/playwright';

test('debug page state', async ({ page, serve }) => {
  const { url } = await serve('./dist/index.html');

  await page.goto(url);
  await page.pause();
});

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 8, 2026

Copy link
Copy Markdown

Deploying rstest with  Cloudflare Pages  Cloudflare Pages

Latest commit: 07c8abd
Status: ✅  Deploy successful!
Preview URL: https://f8524861.rstest.pages.dev
Branch Preview URL: https://9aoy-feat-rstest-playwright.rstest.pages.dev

View logs

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

Rsdoctor Bundle Diff Analysis

Found 14 projects in monorepo, 3 projects with changes.

📊 Quick Summary
Project Total Size Change
adapter-rsbuild 5.4 KB 0
adapter-rslib 25.6 KB 0
adapter-rspack 9.3 KB 0
browser 2.0 MB 0
browser-react 6.4 KB 0
browser-ui 808.2 KB 0
coverage-istanbul 18.8 KB 0
coverage-v8 19.4 KB 0
playwright 23.1 KB -
core/browser 1.1 MB +138.0 B (0.0%)
core/loaders 869.0 B 0
core/main 1.9 MB +138.0 B (0.0%)
vscode/extension 27.1 MB 0
vscode/worker 14.5 KB 0
📋 Detailed Reports (Click to expand)

📁 playwright

Path: packages/playwright/.rsdoctor/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 23.1 KB - -
📄 JavaScript 23.1 KB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 core/browser

Path: packages/core/.rsdoctor/browser/rsdoctor-data.json

📌 Baseline Commit: 84ccf9e4cf | PR: #1426

Metric Current Baseline Change
📊 Total Size 1.1 MB 1.1 MB +138.0 B (0.0%)
📄 JavaScript 973.7 KB 973.6 KB +37.0 B (0.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 114.7 KB 114.6 KB +101.0 B (0.1%)

📦 Download Diff Report: core/browser Bundle Diff

📁 core/main

Path: packages/core/.rsdoctor/main/rsdoctor-data.json

📌 Baseline Commit: 84ccf9e4cf | PR: #1426

Metric Current Baseline Change
📊 Total Size 1.9 MB 1.9 MB +138.0 B (0.0%)
📄 JavaScript 1.6 MB 1.6 MB +37.0 B (0.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 293.9 KB 293.8 KB +101.0 B (0.0%)

📦 Download Diff Report: core/main Bundle Diff

Generated by Rsdoctor GitHub Action

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new @rstest/playwright package to enable Playwright-driven E2E testing inside Rstest Node.js workers, and documents the integration in both English and Chinese guides. It also extends the core test context metadata by exposing the current test file path via task.filepath.

Changes:

  • Add @rstest/playwright package with Playwright fixtures (browser/context/page/request/serve) and retrying Playwright-style assertions layered on top of Rstest expect.
  • Add package-level/unit tests plus an e2e/playwright fixture project to validate integration end-to-end.
  • Add English/Chinese documentation pages and navigation metadata; add task.filepath to core runner context.

Reviewed changes

Copilot reviewed 26 out of 27 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
website/docs/en/guide/integration/playwright.mdx English integration guide for @rstest/playwright.
website/docs/en/guide/integration/_meta.json Adds Playwright page to EN integration nav.
website/docs/zh/guide/integration/playwright.mdx Chinese integration guide for @rstest/playwright.
website/docs/zh/guide/integration/_meta.json Adds Playwright page to ZH integration nav.
pnpm-lock.yaml Locks new workspace package + Playwright deps for fixtures.
packages/playwright/tsconfig.json TypeScript build config for the new package.
packages/playwright/tests/tsconfig.json TypeScript config for package tests.
packages/playwright/tests/fixture.test.ts Tests for fixtures (request, serve, options overrides, helper preservation).
packages/playwright/tests/expect.test.ts Tests for retrying locator/page assertions and message handling.
packages/playwright/src/index.ts Public entry exports for fixtures/expect/types.
packages/playwright/src/fixture.ts Implements Playwright fixtures + static server + debug behavior.
packages/playwright/src/expect.ts Implements Playwright-style retrying assertions via proxied expect.
packages/playwright/rstest.config.ts Rstest config for running package tests.
packages/playwright/rslib.config.ts rslib build config and externals for publishing.
packages/playwright/README.md Package README mirroring docs usage/config.
packages/playwright/package.json New published package manifest + deps/peers/scripts.
packages/playwright/AGENTS.md Package contribution guidelines and commands.
packages/core/src/types/api.ts Adds task.filepath to TestContext typing.
packages/core/src/runtime/runner/runner.ts Populates context.task.filepath at runtime.
knip.jsonc Adds knip entry for packages/playwright test files.
e2e/playwright/index.test.ts E2E harness to run fixture project via CLI.
e2e/playwright/fixtures/package.json Fixture project deps for E2E validation.
e2e/playwright/fixtures/rstest.config.mts Fixture project Rstest config (node env, isolate false).
e2e/playwright/fixtures/rsbuild.config.ts Fixture project Rsbuild config to generate a page.
e2e/playwright/fixtures/src/index.ts Fixture app entry content.
e2e/playwright/fixtures/index.test.ts E2E test using page + serve + assertions.
e2e/playwright/fixtures/debug.test.ts E2E test validating debug env behavior (plus a skipped pause test).
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/playwright/src/fixture.ts
Comment thread packages/playwright/src/fixture.ts
Comment thread website/docs/en/guide/integration/playwright.mdx Outdated
Comment thread website/docs/zh/guide/integration/playwright.mdx Outdated
Comment thread packages/core/src/types/api.ts
Comment thread packages/playwright/src/fixture.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 26 out of 27 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/playwright/src/fixture.ts Outdated
Comment thread packages/playwright/src/fixture.ts
Comment thread packages/core/src/types/api.ts
Comment thread packages/core/src/runtime/runner/runner.ts
@9aoy

9aoy commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb4f3cf19e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/playwright/src/expect.ts
Comment thread packages/playwright/src/fixture.ts Outdated
Comment thread packages/playwright/src/fixture.ts Outdated
Comment thread packages/playwright/package.json Outdated
Comment thread packages/playwright/src/fixture.ts Outdated
Comment thread packages/playwright/src/fixture.ts Outdated
Comment thread packages/playwright/src/expect.ts Outdated
@fi3ework

Copy link
Copy Markdown
Member

I just remembered: could this PR resolve the excessive boilerplate code found in this file?

@9aoy

9aoy commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

I just remembered: could this PR resolve the excessive boilerplate code found in this file?

Sure, it provides browser, context, page, request, and static serve fixtures,

@fi3ework

fi3ework commented Jun 24, 2026

Copy link
Copy Markdown
Member

#1376 merged, non blocking bug for web-infra-dev/rsbuild#7776.

what about release preview version of this PR to verify Playwright integration with web-infra-dev/rsbuild#7776?

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.

3 participants