with <v10.0.0-beta.59> it seems not to be possible...
# pact-js
a
with v10.0.0-beta.59 it seems not to be possible to have in one interaction multiple provider states with the same name. That was possible in .36. Is that a bug or a feature? My use-case is to create multiple files. So I call multiple times `
Copy code
provider.given('file exists', { username, password, fileName: resource })
but in the JSON I only have one providerstate with that name
Copy code
"providerStates": [
        {
          "name": "the user is recreated",
          "params":...
        },
        {
          "name": "file exists",
          "params": {
            "fileName": "testFolder/文件.txt",
            "password": "test123",
            "username": "test123"
          }
        },
        {
          "name": "resource is shared",
          "params": ...
        }
      ]
Making the names of provider states individual makes them appear in the JSON, but that would mean I would also have to have an individual state definition in the provider tests (stateHandlers)
m
hmmm it seems like that would have been a bug in the core that has been resolved (I don’t know why/where just yet). The name of the state I think needs to be unique
@uglyog is my assumption correct? If not, I’ll see if I can track down where that assumption is built in code (whether JS or somewhere else)
u
It may have been an accidental feature, I don't recall doing that by design
m
Should it be possible to have multiple provider states with the same description (but different params?)
u
But then it has been a while, and maybe I just don't recall what I was doing back then
m
I assume not
a
if the same description is not allowed, then my tests cannot have just arbitrary filenames, but the names have to be part of the description, or some kind of counter is needed
u
The provider states are not keyed, so you could have multiple in the Pact file with the same description. I don't know what the effect will be. But I assume it will just loop though the list and call the handler based on the name
a
that would be my expectation
u
Just checked Pact-JVM, uniqueness is description + parameters
m
Cool. I'll see if I can track down where the issue is
It might be there is a keyed state somewhere so it's overridden
Your use case makes sense actually
a
the stateHandler on the provider side is happy with the same names, just loops. So the issue is on the side of writing to the JSON
👍 1
any news on this? Should I create an issue to track it?
m
yes please!