| name | eventuras-testing |
| description | Running and managing tests in the Eventuras monorepo (xUnit backend tests, Playwright E2E tests, integration tests) |
| license | MIT |
Eventuras Testing Skill
Overview
This skill provides comprehensive testing capabilities for the Eventuras monorepo, covering backend xUnit tests, frontend Playwright E2E tests, and integration testing patterns.
Backend Testing (C# .NET)
Running All Backend Tests
cd apps/api
dotnet test
Running Specific Test Project
dotnet test tests/Eventuras.UnitTests
dotnet test tests/Eventuras.IntegrationTests
dotnet test tests/Eventuras.WebApi.Tests
Running Specific Test Class
dotnet test --filter "FullyQualifiedName~Eventuras.WebApi.Tests.EventsControllerTests"
Running Specific Test Method
dotnet test --filter "FullyQualifiedName~Eventuras.WebApi.Tests.EventsControllerTests.GetEvents_ShouldReturnOk"
Running Tests with Verbose Output
dotnet test --logger "console;verbosity=detailed"
Running Tests with Code Coverage
dotnet test /p:CollectCoverage=true /p:CoverageReportsDirectory=./coverage
Frontend E2E Testing (Playwright)
Running All E2E Tests
cd apps/web-e2e
pnpm test
Running Specific Test File
cd apps/web-e2e
pnpm playwright test playwright-e2e/admin-events.spec.ts
Running Tests in UI Mode (for debugging)
cd apps/web-e2e
pnpm playwright test --ui
Running Tests in Headed Mode
cd apps/web-e2e
pnpm playwright test --headed
Running Tests for Specific Browser
cd apps/web-e2e
pnpm playwright test --project=chromium
pnpm playwright test --project=firefox
pnpm playwright test --project=webkit
Show Test Report
cd apps/web-e2e
pnpm playwright show-report
Integration Testing
Database Setup
Integration tests use a PostgreSQL database. Connection string:
Host=localhost;Port=5432;Database=eventuras_test;Username=postgres;Password=postgres
The database is automatically configured when running in GitHub Actions environment.
Authentication in Tests
Backend integration tests use mock authentication:
var client = _factory.CreateClient().AuthenticatedAsSystemAdmin();
var client = _factory.CreateClient().AuthenticatedAs(user.Entity);
var client = _factory.CreateClient().AuthenticatedAs(admin.Entity, Roles.Admin);
var client = _factory.CreateClient().Authenticated(role: "Admin");
Frontend E2E tests use setup projects defined in playwright.config.ts:
admin.auth.setup.ts - Admin authentication
user.auth.setup.ts - User authentication
Common Testing Patterns
Backend Test Structure
[Fact]
public async Task MethodName_Scenario_ExpectedBehavior()
{
var client = _factory.CreateClient().AuthenticatedAsSystemAdmin();
var eventData = new EventDto { };
var response = await client.PostAsync("/api/v3/events", eventData);
response.StatusCode.Should().Be(HttpStatusCode.Created);
var result = await response.Content.ReadFromJsonAsync<EventDto>();
result.Should().NotBeNull();
}
Frontend E2E Test Structure
test('should create new event', async ({ page }) => {
await page.goto('/admin/events');
await page.getByRole('button', { name: 'New Event' }).click();
await page.getByLabel('Title').fill('Test Event');
await page.getByRole('button', { name: 'Save' }).click();
await expect(page.getByText('Event created successfully')).toBeVisible();
});
Test Debugging Tips
Backend Tests
- Set breakpoints in Visual Studio Code or Visual Studio
- Use Test Explorer to run individual tests
- Check test output for detailed error messages
- Use
--logger "console;verbosity=detailed" for more information
Frontend E2E Tests
- Use
--ui mode for interactive debugging
- Use
--headed mode to see browser actions
- Use
--debug flag to pause execution
- Check Playwright trace files for detailed execution
- Use browser DevTools for inspecting elements
Running Tests from Monorepo Root
pnpm test
pnpm --filter @eventuras/web test
cd apps/api && dotnet test
CI/CD Testing
Tests run automatically in GitHub Actions:
- Backend tests run on every push
- E2E tests run on PR and main branch
- Database is automatically provisioned
- Test results are reported in PR checks
When to Run Tests
- ✅ Before committing changes
- ✅ After implementing new features
- ✅ After fixing bugs
- ✅ Before creating PRs
- ✅ After updating dependencies
- ✅ When modifying shared libraries
Test Coverage Goals
- Backend API endpoints: >80% coverage
- Business logic services: >90% coverage
- Critical user flows (E2E): 100% coverage
- Shared libraries: >85% coverage