Skip to content
On this page

Empower Your Test Results with AI-Powered Insights ->

Environment Variables

PactumJS allows configurations to be defined through environment variables.

List of Environment Variables

Variable NameDefaultsDescription
PACTUM_MOCK_HOST0.0.0.0Mock Server Hostname/Interface to run on
PACTUM_MOCK_PORT9393Mock server port
PACTUM_REQUEST_BASE_URLEmpty stringSets request base url for all requests
PACTUM_REQUEST_TIMEOUT3000 msSets default timeout of requests
PACTUM_RESPONSE_TIMEnullSets default expected response time
PACTUM_RESPONSE_STATUSnullSets default expected response status code
PACTUM_DISABLE_USE_INTERACTIONnullDisable use interactions

Usage

✅ Correct Usage

Setting ENV variables from shell or CI/CD.

sh
# Set the environment variable from shell as shown in example below
export PACTUM_MOCK_HOST=localhost
export PACTUM_MOCK_PORT=9001
export PACTUM_REQUEST_BASE_URL=https://example.com

Adding to .env file and read it through dotenv package.

sh
# contents in .env file
PACTUM_MOCK_HOST=localhost
PACTUM_MOCK_PORT=9001
PACTUM_REQUEST_BASE_URL=https://example.com

See Also

Released under the MIT License.