Running TUnit Tests with Playwright

VerifiedSafe

Run TUnit tests with Playwright for a Blazor application. Use commands to execute all tests, limit parallelism to prevent overload, filter by class or test name with treenode filters, and generate detailed console or TRX reports. Helpful when you need to verify test results or debug failing tests.

Sby Skills Guide Bot
TestingIntermediate
6/2/2026
Claude CodeCursorWindsurf
#tunit#playwright#dotnet#test-automation

Recommended for

Automated summary

Runs TUnit tests with Playwright in a .NET project, with options for parallelism, filtering, and report generation.

Strengths

  • Supports filtering by class, test name, or wildcard via treenode-filter
  • Manages parallelism to prevent system overload
  • Detailed console and TRX report formats
  • Flakiness mitigation with automatic retries and sequential execution

Limitations

  • Requires specific project structure (SummitUI.Tests.Playwright)
  • Filters use a complex path pattern (assembly/namespace/class/test)
  • Depends on .NET SDK being installed
When to use it

When you need to run a Playwright test suite in a .NET TUnit project, with control over parallelism and test filtering.

When not to use it

For simple unit tests without browser interaction, prefer a lighter framework like xUnit or NUnit without Playwright.

Security analysis

Safe
Quality score90/100

The skill only provides instructions for running dotnet test commands and does not perform any destructive actions, external network calls, or exfiltration. No obfuscated or unsafe commands are present.

No concerns found

How this analysis is made

Examples

Run all tests with limited parallelism
Run all TUnit Playwright tests with maximum 1 parallel test.
Run tests by class name
Run all tests in the SelectAccessibilityTests class.
Run a specific test
Run the test named Trigger_ShouldHave_RoleCombobox.

name: tunit description: Run TUnit tests with Playwright. Use when user asks to run tests, execute tests, or check if tests pass.

Running TUnit Tests

This project uses TUnit with Playwright for testing. Tests are located in tests/SummitUI.Tests.Playwright/.

Run All Tests

dotnet run --project tests/SummitUI.Tests.Playwright

Run Tests with Limited Parallelism (Recommended)

To prevent system overload when running Playwright tests, limit parallel test execution:

# Run with maximum 1 parallel test (sequential)
dotnet run --project tests/SummitUI.Tests.Playwright -- --maximum-parallel-tests 1

# Run with maximum 8 parallel tests
dotnet run --project tests/SummitUI.Tests.Playwright -- --maximum-parallel-tests 8

Run Tests with Filters

TUnit uses --treenode-filter with path pattern: /assembly/namespace/class/test

Filter by class name:

dotnet run --project SummitUI.Tests.Playwright -- --treenode-filter '/*/*/ClassName/*'

Filter by exact test name:

dotnet run --project SummitUI.Tests.Playwright -- --treenode-filter '/*/*/*/TestName'

Examples:

# Run all Select accessibility tests
dotnet run --project tests/SummitUI.Tests.Playwright -- --treenode-filter '/*/*/SelectAccessibilityTests/*'

# Run specific test by name
dotnet run --project tests/SummitUI.Tests.Playwright -- --treenode-filter '/*/*/*/Trigger_ShouldHave_RoleCombobox'

# Run tests matching pattern (wildcard in test name)
dotnet run --project tests/SummitUI.Tests.Playwright -- --treenode-filter '/*/*/*/Keyboard*'

# Run all tests in namespace
dotnet run --project tests/SummitUI.Tests.Playwright -- --treenode-filter '/*/SummitUI.Tests.Playwright/*/*'

Run Tests in Debug Mode

When a debugger is attached, Playwright will run in debug mode (PWDEBUG=1) automatically via the Hooks.cs setup.

View Test Output

Add --report flags for different output formats:

# Console output with details
dotnet run --project tests/SummitUI.Tests.Playwright -- --output-format console-detailed

# Generate TRX report
dotnet run --project tests/SummitUI.Tests.Playwright -- --report-trx

Flakiness Mitigation

The test project includes several features to reduce flakiness:

  1. Automatic Retries: Tests are automatically retried up to 2 times on failure ([Retry(2)] in GlobalSetup.cs)
  2. Fully Sequential Execution: All tests run sequentially via [assembly: NotInParallel] in GlobalSetup.cs
  3. Server Readiness Check: Hooks.cs waits for the Blazor server to be fully ready before tests start
  4. Extended Timeouts: Configured via tunit.json for longer test and hook timeouts

Project Structure

  • GlobalSetup.cs - Assembly-level test configuration (retries, parallelism)
  • Hooks.cs - Test session setup/teardown (starts Blazor server)
  • BlazorWebApplicationFactory.cs - WebApplicationFactory for hosting the test server
  • tunit.json - TUnit configuration file
  • *AccessibilityTests.cs - Accessibility test classes inheriting from PageTest

Test Conventions

  • Tests inherit from TUnit.Playwright.PageTest to get Page access
  • Use [Before(Test)] for per-test setup
  • Use [Before(TestSession)] / [After(TestSession)] for session-wide setup
  • Access the running server via Hooks.ServerUrl

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/running-tunit-tests-with-playwright-mm5t89la/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/running-tunit-tests-with-playwright-mm5t89la' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/running-tunit-tests-with-playwright-mm5t89la/download' --output '.skill-downloads/running-tunit-tests-with-playwright-mm5t89la/SKILL.md.part' && mv '.skill-downloads/running-tunit-tests-with-playwright-mm5t89la/SKILL.md.part' '.skill-downloads/running-tunit-tests-with-playwright-mm5t89la/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/running-tunit-tests-with-playwright-mm5t89la/SKILL.md' && test -s '.skill-downloads/running-tunit-tests-with-playwright-mm5t89la/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/tunit' && cp -R '.skill-downloads/running-tunit-tests-with-playwright-mm5t89la' '.claude/skills/tunit'

Cursor
test -f '.skill-downloads/running-tunit-tests-with-playwright-mm5t89la/SKILL.md' && test -s '.skill-downloads/running-tunit-tests-with-playwright-mm5t89la/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/tunit' && cp -R '.skill-downloads/running-tunit-tests-with-playwright-mm5t89la' '.cursor/skills/tunit'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/running-tunit-tests-with-playwright-mm5t89la'

openskills read 'running-tunit-tests-with-playwright-mm5t89la'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/running-tunit-tests-with-playwright-mm5t89la/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills