Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions TUnit.Playwright/BrowserFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ public class BrowserFixture : IAsyncInitializer, IAsyncDisposable

public virtual string BrowserName => Microsoft.Playwright.BrowserType.Chromium;

protected virtual BrowserTypeLaunchOptions GetLaunchOptions() => new()
{
Headless = TUnitPlaywrightSettings.Default.DefaultHeadless,
};
protected virtual BrowserTypeLaunchOptions GetLaunchOptions() =>
TUnitPlaywrightSettings.Default.DefaultBrowserTypeLaunchOptions ?? new BrowserTypeLaunchOptions();

public virtual async Task InitializeAsync()
{
Expand Down
5 changes: 1 addition & 4 deletions TUnit.Playwright/BrowserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ namespace TUnit.Playwright;

public class BrowserTest : PlaywrightTest
{
public BrowserTest() : this(new BrowserTypeLaunchOptions
{
Headless = TUnitPlaywrightSettings.Default.DefaultHeadless,
})
public BrowserTest() : this(TUnitPlaywrightSettings.Default.DefaultBrowserTypeLaunchOptions ?? new BrowserTypeLaunchOptions())
{
}

Expand Down
3 changes: 1 addition & 2 deletions TUnit.Playwright/ContextFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ public class ContextFixture : IAsyncInitializer, IAsyncDisposable
/// (<c>new BrowserNewContextOptions()</c>).
/// </summary>
protected virtual BrowserNewContextOptions GetContextOptions() =>
new()
TUnitPlaywrightSettings.Default.DefaultBrowserNewContextOptions ?? new BrowserNewContextOptions
{
Locale = "en-US", ColorScheme = ColorScheme.Light,
IgnoreHTTPSErrors = TUnitPlaywrightSettings.Default.DefaultIgnoreHttpsErrors,
};

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions TUnit.Playwright/ContextTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ public ContextTest(BrowserTypeLaunchOptions options) : base(options)

public virtual BrowserNewContextOptions ContextOptions(TestContext testContext)
{
return new()
return TUnitPlaywrightSettings.Default.DefaultBrowserNewContextOptions ?? new BrowserNewContextOptions
{
Locale = "en-US", ColorScheme = ColorScheme.Light,
IgnoreHTTPSErrors = TUnitPlaywrightSettings.Default.DefaultIgnoreHttpsErrors,
};
}

Expand Down
15 changes: 13 additions & 2 deletions TUnit.Playwright/PlaywrightSettings.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Microsoft.Playwright;
using TUnit.Core.Settings;

namespace TUnit.Playwright;
Expand All @@ -18,6 +19,16 @@ internal TUnitPlaywrightSettings()
{
}

public bool? DefaultHeadless { get; set; } = null;
public bool? DefaultIgnoreHttpsErrors { get; set; } = null;
/// <summary>
/// Options used when launching the browser for tests inheriting <see cref="BrowserTest"/>
/// or <see cref="BrowserFixture"/>. When non-null, this fully replaces the hardcoded defaults.
/// </summary>
public BrowserTypeLaunchOptions? DefaultBrowserTypeLaunchOptions { get; set; } = null;

/// <summary>
/// Options used when creating a browser context for tests inheriting <see cref="ContextTest"/>
/// or <see cref="ContextFixture"/>. When non-null, this fully replaces the hardcoded defaults
/// (<c>Locale = "en-US"</c>, <c>ColorScheme = Light</c>).
/// </summary>
public BrowserNewContextOptions? DefaultBrowserNewContextOptions { get; set; } = null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ namespace
}
public class TUnitPlaywrightSettings
{
public bool? DefaultHeadless { get; set; }
public bool? DefaultIgnoreHttpsErrors { get; set; }
public .BrowserNewContextOptions? DefaultBrowserNewContextOptions { get; set; }
public .BrowserTypeLaunchOptions? DefaultBrowserTypeLaunchOptions { get; set; }
}
public class WorkerAwareTest : ., .
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ namespace
}
public class TUnitPlaywrightSettings
{
public bool? DefaultHeadless { get; set; }
public bool? DefaultIgnoreHttpsErrors { get; set; }
public .BrowserNewContextOptions? DefaultBrowserNewContextOptions { get; set; }
public .BrowserTypeLaunchOptions? DefaultBrowserTypeLaunchOptions { get; set; }
}
public class WorkerAwareTest : ., .
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ namespace
}
public class TUnitPlaywrightSettings
{
public bool? DefaultHeadless { get; set; }
public bool? DefaultIgnoreHttpsErrors { get; set; }
public .BrowserNewContextOptions? DefaultBrowserNewContextOptions { get; set; }
public .BrowserTypeLaunchOptions? DefaultBrowserTypeLaunchOptions { get; set; }
}
public class WorkerAwareTest : ., .
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ namespace
}
public class TUnitPlaywrightSettings
{
public bool? DefaultHeadless { get; set; }
public bool? DefaultIgnoreHttpsErrors { get; set; }
public .BrowserNewContextOptions? DefaultBrowserNewContextOptions { get; set; }
public .BrowserTypeLaunchOptions? DefaultBrowserTypeLaunchOptions { get; set; }
}
public class WorkerAwareTest : ., .
{
Expand Down
Loading