diff --git a/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs b/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs
index b79162188..778d68fbb 100644
--- a/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs
+++ b/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs
@@ -14,6 +14,10 @@ using Microsoft.Playwright;
///
public class PlaywrightTest
{
+ private static readonly object _lock = new object();
+ private static int _basePort = 5600;
+ private static int _currentPort = _basePort;
+
///
/// For starting the WebAPI project in-memory.
///
@@ -66,9 +70,16 @@ public class PlaywrightTest
[OneTimeSetUp]
public async Task OneTimeSetUp()
{
- // Determine random port for the WebAPI between 5100-5900. The WASM app will run on the next port.
- var apiPort = new Random().Next(5100, 5900);
- var appPort = apiPort + 1;
+ // Set the base port for the test starting at 5600. Increase the port by 2 for each test running
+ // in parallel to avoid port conflicts.
+ var apiPort = 0;
+ var appPort = 0;
+ lock (_lock)
+ {
+ apiPort = Interlocked.Increment(ref _currentPort);
+ appPort = Interlocked.Increment(ref _currentPort);
+ }
+
AppBaseUrl = "http://localhost:" + appPort + "/";
// Start WebAPI in-memory.
diff --git a/src/Tests/AliasVault.E2ETests/Common/TestDefaults.cs b/src/Tests/AliasVault.E2ETests/Common/TestDefaults.cs
index c6f11aaf1..bcce9a641 100644
--- a/src/Tests/AliasVault.E2ETests/Common/TestDefaults.cs
+++ b/src/Tests/AliasVault.E2ETests/Common/TestDefaults.cs
@@ -15,5 +15,5 @@ public static class TestDefaults
///
/// Gets or sets default timeout while waiting for pages to load in milliseconds.
///
- public static int DefaultTimeout { get; set; } = 10000;
+ public static int DefaultTimeout { get; set; } = 15000;
}