aboutsummaryrefslogtreecommitdiffstats
path: root/test/runner/lib/buildTestUrl.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/runner/lib/buildTestUrl.js')
-rw-r--r--test/runner/lib/buildTestUrl.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/runner/lib/buildTestUrl.js b/test/runner/lib/buildTestUrl.js
new file mode 100644
index 000000000..6e0f1a9b0
--- /dev/null
+++ b/test/runner/lib/buildTestUrl.js
@@ -0,0 +1,29 @@
+import { generateModuleId } from "./generateHash.js";
+
+export function buildTestUrl( modules, { browserstack, esm, jsdom, port, reportId } ) {
+ if ( !port ) {
+ throw new Error( "No port specified." );
+ }
+
+ const query = new URLSearchParams();
+ for ( const module of modules ) {
+ query.append( "moduleId", generateModuleId( module ) );
+ }
+
+ if ( esm ) {
+ query.append( "esmodules", "true" );
+ }
+
+ if ( jsdom ) {
+ query.append( "jsdom", "true" );
+ }
+
+ if ( reportId ) {
+ query.append( "reportId", reportId );
+ }
+
+ // BrowserStack supplies a custom domain for local testing,
+ // which is especially necessary for iOS testing.
+ const host = browserstack ? "bs-local.com" : "localhost";
+ return `http://${ host }:${ port }/test/?${ query }`;
+}