Given the API base URL is "url"

This step sets the base URL that is prepended to all endpoint paths in the scenario. When the supplied value begins with http:// or https://, it is used as-is after stripping any trailing slash. When the value is a relative path, it is joined onto the LAUNCH_URL environment variable, or http://localhost:8080 if that variable is not set. This lets tests run against different environments simply by changing LAUNCH_URL without editing feature files.

Call this step once, usually near the top of the scenario or in a Background block. All subsequent request steps within the scenario will prepend this base URL. Three equivalent phrasings are available to suit different team writing styles.

Accepted phrasings

Given the API base URL is "https://api.example.org"
Given I set the API base URL to "https://api.example.org"
Given the base URL is "https://api.example.org"

Examples

Given the API base URL is "https://api.example.org/v1"
Given I set the API base URL to "https://api.example.org/v1"
Given the base URL is "http://localhost:3000/api"
Given I set the API base URL to "/api/v2"

In a real scenario

Scenario: Health-check endpoint returns 200 OK
  Given the API base URL is "https://api.example.org"
  And I set header "Accept" with value "application/json"
  When I send a GET request to "/health"
  Then the API response code should be 200
  And the API response should contain "ok"

Related steps

Back to Api Steps