I’m trying to test URL query parameters in my editor workflow, but I’m running into issues.
I have a workflow that should read URL query parameters on page load. I tried using:
const queryParams = Browser.query;
console.log(queryParams);
When I paste a query string right after the page path in the editor URL, Browser.query is empty. If I reload the page with a new query string, it redirects to the home page, so I can’t test my workflow. I also tried creating ?query variables, but that didn’t work either.
Is there a way to simulate query strings for testing purposes?
             
            
              
              
              
            
           
          
            
            
              Instead of relying on Browser.query, you can read the query string from the browser’s location object. In most editors or client-side apps, this works reliably:
const queryParams = new URLSearchParams(window.location.search);
console.log(queryParams.get("myParam")); // prints the value of ?myParam=value
This avoids any editor-specific behavior and works even when the editor API doesn’t populate Browser.query.
             
            
              
              
              
            
           
          
            
            
              If loading a URL with query parameters triggers a redirect, you can simulate query parameters in your tests by manually updating the window.history:
// Simulate URL with query parameters
const url = new URL(window.location);
url.searchParams.set("myParam", "testValue");
window.history.replaceState({}, "", url);
// Now your workflow can read it
const queryParams = new URLSearchParams(window.location.search);
console.log(queryParams.get("myParam")); // "testValue"
This way, you can test your workflow logic without a full page reload or triggering redirects.
             
            
              
              
              
            
           
          
            
            
              Some editor environments allow passing “preview data” or “context variables” to simulate URL parameters. If Browser.query is empty, you can inject a mock object during testing:
// In your test setup
const mockQuery = { myParam: "testValue" };
window.Browser = { query: mockQuery };
// Then in your workflow
console.log(Browser.query.myParam); // "testValue"
This is especially useful for unit testing workflows without relying on real URLs.