Use test host configuration to set playwright options. #3
Replies: 2 comments
-
My knowledge is limited in Playwright framework... but what I have gathered for Playwright configuration... |
Beta Was this translation helpful? Give feedback.
-
@eric-vanartsdalen Playwright uses a number of POCO configuration objects to performs various operations, such as
I think we are generally in agreement here on the customization that can be done. See I've added a couple of example fixtures to show injecting/overriding configuration in the test and/or fixture. |
Beta Was this translation helpful? Give feedback.
-
From #1 there is a possibility to load configuration for
PlaywrightWebApplicationFactory
from the host under test.This would allow many options to be set without overriding the respective property get function:
BrowserType
LaunchOptions
ContextOptions
PageOptions
It would need to be decided what the configuration section name should be (at least by default) for these. In the proof of concept, I used.
To separate settings for the host, from the test factory, it might make sense to load additional setting from an
appSettings.json
file in the test project, and/or from user secret linked to the test project.The former can be achieved by code like
which could be called from
CreateHost
and the latter byagain in
CreateHost
.Technically, we could do something like
Which would work if the factory was subclassed as a fixture in the test project.
There is also a
GetTestAssemblies
function in the baseMicrosoft.AspNetCore.Mvc.Testing.WebApplicationFactory
which could perhaps be used.So, the questions are:
appSettings.json
(or similar) be added from the test project by default?If should be possible to add predicate properties to allow overriding the default behaviour fairly easily - like
C3D.Extensions.Playwright.AspNetCore/src/C3D/Extensions/Playwright/AspNetCore.Xunit/Fixtures/PlaywrightFixture.cs
Lines 13 to 21 in d967c9e
Beta Was this translation helpful? Give feedback.
All reactions