defunctzombie/zuul

Is there a way to know what the ZUUL_PORT is from the tests?

Closed this issue · 7 comments

I have some tests that require some requests to be crossdomain. I am using a support server written to listen on ZUUL_PORT and that works fine. If I log the port and set my tests to use that port for the crossdomain requests after the server starts they work.

Is this exposed at all in the tests so that I don't have that manual step of getting the port number and putting it into my tests?

What I have done in the past if needed, is create an endpoint on my support server /port and just fetched that in a before hook using basic ajax.

I think we could expose this and other zuul configs via a ZUUL global without much fuss tho so you wouldn't need to have the above hack.

vvo commented

Having the current browser + version as an environement var would be very useful too.

Thanks @defunctzombie that sounds like a good workaround. Agreed that eventually it would be nice to have that stuff available.

@vvo what's the use case you had in mind for the browser and version?

vvo commented

@rase- :

if (process.env.BROWSER === 'ie8') {
  test('it should work with specific ie8 fallback', function() {

  });
}

Let's say you have an ajax request wrapper which does use XDomainRequest on ie8 then you would
like to test this. Of course feature detection is always better but since we exactly know what's the current tested browser, might be good.

But then in --local mode, this would fail badly.

Yeah I would strongly prefer feature detection in those cases. It also makes it clearer what exactly the browser should have/should not have for that functionality to exist.

@defunctzombie

What I have done in the past if needed, is create an endpoint on my support server /port and just fetched that in a before hook using basic ajax.

Uhm, I don't get this: How do you fetch the /port route if you do not yet know the port?

I think we could expose this and other zuul configs via a ZUUL global without much fuss tho so you wouldn't need to have the above hack.

Is something such as this actually available?

Or: How do I get the ZUUL_PORT from within my tests so that I know what to connect to?