eykrehbein / strest

⚡️ CI-ready tests for REST APIs configured in YAML
MIT License
1.74k stars 59 forks source link

Issue with Env() on Mac OS and node 8 #61

Closed ncuster closed 6 years ago

ncuster commented 6 years ago

On Mac OS 10.13.6, with node 8.11.3, I have a test such as requests: login: url: Env(URL) method: POST .... ....

I set URL in my env to http://foo.com/bar, but when I run the test it errors saying it can't talk to 127.0.0.1 for the url. Exact error:

strest ./post.yml

[ Strest ] Found 1 test file(s) [ Strest ] Schema validation: 1 of 1 file(s) passed

✖ Testing login failed (0.041s)

Error: connect ECONNREFUSED 127.0.0.1:80

I took the exact same version of strest, same strest test file, same env variable set, on a linux box with node 6.14.0 and the test works correctly (uses http://foo.com/bar). It seems as though the Env call on node 8 doesn't recognize my environment variable on node8+MacOS but does on node6+Linux. I did some googling but couldn't find if there was some changes or issues with getting the env in node 8 vs. 6. On node 8 I made a one-liner node app to print process.env and I see my environment (including URL) so I don't think there is. Maybe an issue with the templating/yaml parsing between versions where the Env() call exists?

eykrehbein commented 6 years ago

Have you defined your Env variable in the .bash_profile file or in the terminal? Because I ran into the same issue when I defined it in the terminal on MacOS and node6/8. But when I made a new entry into the ~/.bash_profile file and restarted my terminal it has worked correctly

jgroom33 commented 6 years ago

Is the behavior different if export FOO=bar.com is used?

eykrehbein commented 6 years ago

Yes unfortunately it will be undefined

ncuster commented 6 years ago

I have tried a few things, and still have the same problem: export URL=foo && strest # what I originally tried, doesn't work URL=foo strest # var inline, doesn't work put URL=foo in ~/.bash_profile and then ran strest # doesn't work

shrikster commented 6 years ago

can you share your post.yml file ?

ncuster commented 6 years ago

This is a test case that is similar to mine:

foo.strest.yml:

version: 1

requests:
  login:
    url: Env(URL)
    method: GET
    log: true

export URL=https://www.google.com strest ./foo.strest.yml

Yields the following: [ Strest ] Found 1 test file(s) [ Strest ] Schema validation: 1 of 1 file(s) passed

✖ Testing login failed (0.035s)

Error: connect ECONNREFUSED 127.0.0.1:80

[ Strest ] Failed before finishing all requests

eykrehbein commented 6 years ago

Have you tried to define the ENV variables in your ~/.bash_profile file and then restart your terminal?

ncuster commented 6 years ago

I did try that as well and it still fails.

jgroom33 commented 6 years ago

I suggest this issue is closed. Even if the root cause is determined, handling specific host environments is not something that should be implemented.

ncuster commented 6 years ago

Do we know if this is a Mac OS specific issue, or a node 8 issue? I'll try to test on linux with node 8 and see if I can reproduce.

ncuster commented 6 years ago

I haven't had time to look into this any further, and not sure when I'll have time on MacOS again. So following the advice above and closing.