pactum
pactum copied to clipboard
`PACTUM_REQUEST_BASE_URL` is not working when adding it on `.env`
Describe the bug
I have tried to add the environment variable in the .env
file in the root of the project and it does not work giving the following error:
TypeError [ERR_INVALID_URL]: Invalid URL: /endpoint
at setBaseUrl (node_modules/pactum/src/helpers/requestProcessor.js:33:16)
at Object.process (node_modules/pactum/src/helpers/requestProcessor.js:14:5)
at Tosser.toss (node_modules/pactum/src/models/Tosser.js:30:39)
at Spec.toss (node_modules/pactum/src/models/Spec.js:479:19)
at Spec.then (node_modules/pactum/src/models/Spec.js:483:10)
However if I add it by exporting it it (export PACTUM_REQUEST_BASE_URL=url
) does work
Expected behavior
Adding the variable on the .env
file it works.
Software (please complete the following information):
- OS: MacOS
- Test Runner: Jest
Pactum doesn't read environment variables from .env
file. dotenv will help if we place it at the start of test execution.
Pactum doesn't read environment variables from
.env
file. dotenv will help if we place it at the start of test execution.
Thanks for your answer @ASaiAnudeep
In that case I'm a bit confused by this affirmation in the documentation: "PactumJS supports setting default values to configuration parameters via Envrionment variables. ✅ Correct Usage: Adding to .env file"
Thank you for pointing it out. We will update the docs.