This project contains Playwright-based integration tests for the AfterBlazorServerSide sample application.
These tests verify that:
- Sample pages load successfully without errors
- No console errors occur during page rendering
- Components render correctly
- Navigation works as expected
- Verifies the home page loads successfully
- Checks for console errors
- Validates navigation menu presence
- Verifies the component list page loads
- Checks for console errors
- Validates component links are present
- Tests all control sample pages across different categories:
- Editor Controls (Button, CheckBox, HyperLink, etc.)
- Data Controls (DataList, GridView, Repeater, etc.)
- Navigation Controls (TreeView)
- Validation Controls
- Login Controls
- Other Controls (AdRotator)
Before running the tests, you need to install Playwright browsers:
pwsh samples/AfterBlazorServerSide.Tests/bin/Debug/net10.0/playwright.ps1 installOr on Linux/macOS:
dotnet build samples/AfterBlazorServerSide.Tests
playwright installdotnet test samples/AfterBlazorServerSide.Testsdotnet test samples/AfterBlazorServerSide.Tests --filter "FullyQualifiedName~HomePageTests"dotnet test samples/AfterBlazorServerSide.Tests --verbosity normalThe tests use:
- xUnit as the test framework
- Playwright for browser automation
- WebApplicationFactory to host the sample application in-memory during tests
Each test:
- Starts the Blazor server application
- Launches a headless browser
- Navigates to the test page
- Verifies no errors occur
- Cleans up resources
These tests run automatically in GitHub Actions as part of the integration-tests.yml workflow on:
- Pull requests
- Pushes to main/dev branches
- Manual workflow dispatch
If you get an error about missing browsers, run:
playwright install chromiumThe tests use a random port for each run. If you encounter port issues, ensure no other instances are running.
Some tests have a 30-second timeout. If tests fail with timeout errors, it may indicate:
- Performance issues with the sample application
- Network connectivity problems
- Issues with specific components
To add tests for new sample pages:
- Add the page route to the appropriate
[Theory]inControlSampleTests.cs - Or create a new test class if testing a new feature area
Example:
[Theory]
[InlineData("/ControlSamples/NewControl")]
public async Task NewControl_Loads_WithoutErrors(string path)
{
await VerifyPageLoadsWithoutErrors(path);
}