ComponentTestHostOptions Class

Configures the browser of a ComponentTestHost.

public sealed class ComponentTestHostOptions

Constructors

NameDescription
ComponentTestHostOptions()

ComponentTestHostOptions()

ComponentTestHostOptions.cs
public ComponentTestHostOptions()

No documentation is available.

Properties

NameDescription
BaseUrlGets the URL of the page that hosts the components. It is the base URI of the NavigationManager. The default is https://localhost/.
ConfigureBrowsingContextGets a function that changes the options of the browsing context of the page, or null (see TestPageSettings.ConfigureBrowsingContext).
CustomEventArgsGets the factories of the EventArgs of the custom event types, by DOM event type. The built-in event types (MouseEventArgs, KeyboardEventArgs, ChangeEventArgs...) are created from the DOM events.
DefaultTimeoutGets the maximum time to wait for the components and the page to be idle. The default is 10 seconds.
DocumentLoaderGets the loader of the resources of the page. When it is null, the ComponentTestHostOptions.StaticFiles are served.
EnableJavaScriptGets whether the page runs JavaScript (JavaScriptScriptEngine): the scripts of the host page run, and the JavaScript interop calls that are not set up in ComponentTestHost.JSInterop call the functions of the page.
HostPageGets the HTML of the page that hosts the components: add the style sheets of the application in its head (<link rel=stylesheet> elements are loaded by ComponentTestHostOptions.DocumentLoader). The components are rendered in its body by default.
StaticFilesGets the folders that serve the static files of the host page (style sheets, images, fonts, scripts), by URL path prefix: { "/" : "wwwroot" } serves https://localhost/css/app.css from wwwroot/css/app.css. Ignored when ComponentTestHostOptions.DocumentLoader is set.
StyleSheetsGets the CSS style sheets added to the host page, as the content of <style> elements.
TestIdAttributeGets the name of the attribute that LocatorScope.GetByTestId matches. The default is data-testid.
TimeProviderGets the clock of the timers of the page (setTimeout(), the CSS animations...). The default is the system clock.
ViewportGets the size of the viewport, in CSS pixels. The default is 1280x720.

Gets the URL of the page that hosts the components. It is the base URI of the NavigationManager. The default is https://localhost/.

public string BaseUrl { get; init; }

Property value

string

ConfigureBrowsingContext

ComponentTestHostOptions.cs

Gets a function that changes the options of the browsing context of the page, or null (see TestPageSettings.ConfigureBrowsingContext).

public Func<BrowsingContextOptions, BrowsingContextOptions>? ConfigureBrowsingContext { get; init; }

Gets the factories of the EventArgs of the custom event types, by DOM event type. The built-in event types (MouseEventArgs, KeyboardEventArgs, ChangeEventArgs...) are created from the DOM events.

public IDictionary<string, Func<Event, EventArgs>> CustomEventArgs { get; }

Gets the maximum time to wait for the components and the page to be idle. The default is 10 seconds.

public TimeSpan DefaultTimeout { get; init; }

Property value

TimeSpan

Gets the loader of the resources of the page. When it is null, the ComponentTestHostOptions.StaticFiles are served.

public DocumentLoader? DocumentLoader { get; init; }

Property value

DocumentLoader?

Gets whether the page runs JavaScript (JavaScriptScriptEngine): the scripts of the host page run, and the JavaScript interop calls that are not set up in ComponentTestHost.JSInterop call the functions of the page.

public bool EnableJavaScript { get; init; }

Property value

bool

Gets the HTML of the page that hosts the components: add the style sheets of the application in its head (<link rel=stylesheet> elements are loaded by ComponentTestHostOptions.DocumentLoader). The components are rendered in its body by default.

public string HostPage { get; init; }

Property value

string

Gets the folders that serve the static files of the host page (style sheets, images, fonts, scripts), by URL path prefix: { "/" : "wwwroot" } serves https://localhost/css/app.css from wwwroot/css/app.css. Ignored when ComponentTestHostOptions.DocumentLoader is set.

public IDictionary<string, string> StaticFiles { get; }

Gets the CSS style sheets added to the host page, as the content of <style> elements.

public IList<string> StyleSheets { get; }

Property value

IList<string>

Gets the name of the attribute that LocatorScope.GetByTestId matches. The default is data-testid.

public string TestIdAttribute { get; init; }

Property value

string

Gets the clock of the timers of the page (setTimeout(), the CSS animations...). The default is the system clock.

public TimeProvider? TimeProvider { get; init; }

Property value

TimeProvider?

Gets the size of the viewport, in CSS pixels. The default is 1280x720.

public ViewportOptions Viewport { get; init; }

Property value

ViewportOptions