Variable in multi-line expression not resolving
Asked Answered
A

1

6

I have the following scenario that matches the response against a multi-line expression that contains a variable. This variable is defined in karate-config.js and is present because the test succeeds up to the final step.

Background:
  Given url $baseUrl

Scenario: Fetch Root
  Given path "/"
  When method GET
  Then status 200
  And match header Content-Type == $halJson
  And match response ==
  """
  {
    "_links": {
      "user": {
        "href": "$baseUrl/user"
      }
    }
  }
  """

How can I get the baseUrl variable replaced with the real value in the match response step?

Augustaaugustan answered 17/4, 2018 at 20:54 Comment(0)
A
8

With the help of a co-worker I found something that worked

  And match response ==
  """
  {
    "_links": {
      "fpu": {
        "href": '#(baseUrl + "/fpu")'
      }
    }
  }
  """
Augustaaugustan answered 17/4, 2018 at 21:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.