How can I use fromProviderState with path parameter in Pact?

Viewed 32

I am new to pact consumer testing. I am creating consumer pact using JavaScript. To verify with provider I need fromProvderState path parameter. I am using pactV3, here is the code

.given('set id', { id: 52})
        .withRequest({
          method: 'GET',
          path: fromProviderState('data/xml/${id}', 'data/xml/42'),
            headers: {
              Accept: MatchersV3.like(APP_JSON),
              'Content-Type': APP_JSON,
            },           
          })

I tried many example but couldn't make it work. My expectation is something like this

"path": {
  "dataType": "STRING",
  "expression": "data/xml/${id}",
  "type": "ProviderState"
}

In response json file this is what I am getting

"method": "GET",
 "path": "data/xml/42",

Can somebody please help me to solve this issue? Thanks in advance,

1 Answers
Related