install - CoasterFan5/Blazor-Playwright GitHub Wiki
Install and Setup
BUnit
Setup bUnit first, we can use this for unit testing
Add Playwright
Either follow the docs or the instructions below
Next, we need to install Playwright for Dotnet. You can do this by running
dotnet add package Microsoft.Playwright.Xunit
in the tests project directory. We don't need to create a new project for playwright since we have one with xUnit and bUnit already for our other tests. This setup allows both end to end and unit tests.
Now build the project to generate some necessary playwright files:
dotnet build
Now, Playwright has done the useful task of adding a powershell script. If for some reason you have powershell installed, you can run the following:
pwsh bin/Debug/net8.0/playwright.ps1 install
However, most people don't have powershell installed. Rather than something clever, just install Powershell.
# Windows
winget install --id Microsoft.PowerShell --source winget
# MacOS
brew install --cask powershell
Wait but what if I use Linux? You can figure it out
That concludes our installation and setup! Now we can begin writing tests!