imbo / behat-api-extension

API extension for Behat, used to ease testing of JSON-based APIs
MIT License
109 stars 42 forks source link

env variables for base_uri #73

Closed MatthieuMan closed 6 years ago

MatthieuMan commented 6 years ago

do we can une an .env variable for the base_uri value? if yes how? Thanks

christeredvartsen commented 6 years ago

You should be able to do that via the BEHAT_PARAMS environment variable. For instance:

export BEHAT_PARAMS='{"extensions" : {"Imbo\\BehatApiExtension": {"apiClient": {"base_uri": "https://someurl:8080"}}}}'

Just keep in mind that a configuration file has a higher priority in Behat, so if you have a configuration file, and that file specifies a base_uri the value set in the BEHAT_PARAMS environment variable will be ignored.

MatthieuMan commented 6 years ago

So We set the .env file with export BEHAT_PARAMS='{"extensions" : {"Imbo\\BehatApiExtension": {"apiClient": {"base_uri": "https://someurl:8080"}}}}' and how does look the base_uri key in the behat.yml

Imbo\BehatApiExtension:
            apiClient:
                base_uri: ??

thanks

christeredvartsen commented 6 years ago

There is no direct support for .env files in Behat as far as I'm aware.

If you do use an .env file you shouldn't include export on the line though. Your file could for instance look like:

BEHAT_PARAMS='{"extensions" : {"Imbo\\BehatApiExtension": {"apiClient": {"base_uri": "https://someurl:8080"}}}}'

But that file has to be loaded somehow to get the BEHAT_PARAMS into the environment. How you do that is up to you.

How this looks in the behat.yml file is covered in the docs: https://behat-api-extension.readthedocs.io/en/latest/installation/configuration.html#configuration

MatthieuMan commented 6 years ago

thanks