Context
I have Frontend React+Webpack app consuming backend APIs.
My Webpack setup depends on window.location.origin the property, for setting up and deployment processes.
Currently, I'm using Karma testrunner and am trying to replace it with AVA testrunner.
I'm trying to apply AVA with this single entry setup for webpack recipe I'm also applying the JSDOM as dom emulator for the node.
Problem
Some of the tests being bundled, use the location.origin property.
Which throws an error during running webpack && ava script:
var apiUrl = process.env.API_URL && process.env.NODE_ENV !== 'production' ? process.env.API_URL : location.origin;
ReferenceError: location is not defined
Karma runs on browser engine and reproduces the value of window.location.origin dynamically.
With AVA is different. It doesn't run browser of any kind when running test. I can only (as far as I know) "emulate" the browser environment with jsdom, and that is what I am trying to do.
However specific location.origin property is not supported by jsdom
Issue Link
The Question
Could anyone track me to the solution to reproduce the window.location.origin dynamically (environmentally aware) for AVA?
I know that I can put it in constant and store it in .env per each environment.
But this is another maintenance task I would like to mitigate.