-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]: How do you launch the webserver #2369
Comments
You could start it out of process via We internally start it in-process inside a fixture, depending on your application setup, this would work as well. |
Out of process I would love to create an in-process test server. I am struggling to do this at present. If you have any working examples that would run a Blazor WASM application, please do share, as I have been pulling my hair out these past couple of days trying to get a Minimal .net 6 Blazor Wasm started in a Test Server and it's not fun, I know WebApplicationFactory does not support BlazorWasm, No deps file = No WebApplicationFactory... So any other suggestions for an in-process solution would be truly welcome. |
Sorry for the late reply. Is this something which goes into the direction you want? https://github.com/mxschmitt/razor-playwright-dotnet-example |
Hi Max, that looks like an ideal solution. It's along the same lines as Xavier's article which I found just the other day. My solution is made up of a single WASM front-end project and a WebAPI project, and NUnit test project (I guess this will be pretty standard for most people) I've taken Xavier's concept of using the server project to spin up the client. However, I've taken the approach of calling it a test harness or proxy if you prefer and ditching the pages, controllers etc. Simple razor pages project. What my dream is... what, I am trying to achieve is:- It's been proving a challenge but hopefully, it will be worth it, in order to perform fast end-to-end testing in Visual Studio before raising PR's to dev, also hope that the tests can run in the build pipelines rather than having to release in order to perform end-to-end testing... That's the dream. Thanks for the code Max, I will further play with it tomorrow. |
Hi Max, I have just noticed your app is Blazor Server Side. This goal is for a WASM app. |
Hi @mxschmitt, I've prepared a more realistic solution. The main branch is based on your examples and works with Blazor Server. I have also added a second branch, which uses the pure Blazor WASM front-end project, which fails and shows what I am trying to achieve. If you could lend your expertise to overcome this conundrum it would be very much appreciated, not only by me but I guess all automated developers & testers. |
Hi @mxschmitt any ideas regarding the Blazor Wasm example I supplied? |
I have the exact same setup, want to achieve the same goal and ran into the same issues as @carlblanchard |
Still nothing :( It's very disappointing |
Have you tried this? I'm able to start the host, start the WASM To make them work, I used the article and adjust the CreateHost method of CustomWebApplicationFactory by adding the following code to configure the webhost so it's using https, like this :
Now I can test my Blazor WASM application using Playwright. |
The dotnet team did a community stand-up: Playwright testing for Blazor WASM and server: https://github.com/MackinnonBuck/blazor-playwright-example/tree/main https://www.youtube.com/watch?v=lJa3YlUliEs It's using NUnit but thought I would post here as it may be of use. I think that including features like the web server launch in playwright-dotnet API would really be valuable as it is an incredibly common use case. |
Your question
The playwright site does not have advanced documentation for .net.
How would you get Playwright to launch the web server from visual studio 2022?
I would be looking to launch a Blazor Wasm front end along with APIs using WebApplicationFactory, ideally all from within Visual Studio
The text was updated successfully, but these errors were encountered: