public icon indicating copy to clipboard operation
public copied to clipboard

Set hostname for browser runner

Open fvanwijk opened this issue 7 years ago • 4 comments

In Karma there is a configuration setting hostname. Is there also such a setting in Wallaby?

I want window.location.hostname to return localhost.example.com instead of localhost.

fvanwijk avatar Jun 15 '17 07:06 fvanwijk

There's no such setting in wallaby at the moment.

Why would you need to make any assertions for the window.location.hostname? Also, does it actually work for you in karma if you set localhost.example.com? There need to be some host mapping back to localhost for it to work anyway.

ArtemGovorov avatar Jun 15 '17 07:06 ArtemGovorov

I don't want to assert window.location.hostname but my src is depending on the value. Mocking window/location is too much work because some of the properties are readonly.

Test are passing when I set the hostname to localhost.example.com in the karma config. I have a host file with localhost.example.com (and some others) pointing to 127.0.0.1.

fvanwijk avatar Jun 15 '17 08:06 fvanwijk

Fair enough. We'll have a look into what's required to add the feature.

ArtemGovorov avatar Jun 15 '17 08:06 ArtemGovorov

@fvanwijk

If you're using jest you can add a testUrl option:

"jest": {
	"testURL": "http://localhost:3000/",
	"setupFiles": ["<rootDir>/setup-jest.js"],
	"mapCoverage": true,
	"collectCoverageFrom": ["src/js/core/**/*.{js,jsx,ts,tsx}"],
	"testMatch": ["**/?(*.)(spec|test).js?(x)"]
},

screen shot 2018-06-04 at 21 22 42

magicspon avatar Jun 04 '18 20:06 magicspon