Hi all, I've got a question on using the regex fun...
# pact-js
q
Hi all, I've got a question on using the regex function in a willRespondWith. It seems like the pact broker server isn't taking/liking me using regex in willRespondWith. Here's my code:
Copy code
.willRespondWith({
            status: 400,
            headers: {
              "Content-Type": "application/problem+json",
            },
            body: {
              title: "Bad Request",
              detail: regex(
                /.*invalid character.*/,
                'File name *:|.<>+"...jpg contains invalid character(s)'
              ),
            },
          })
However, when I look on the pact broker server, it looks like this:
Copy code
[redacted] will respond with:

{
  "status": 400,
  "headers": {
    "Content-Type": "application/problem+json"
  },
  "body": {
    "detail": "File name *:|.<>+\"...jpg contains invalid character(s)",
    "title": "Bad Request"
  }
}
is there a reason these don't match? Are they supposed to not match? This is throwing an error in my pipeline preventing me from pushing any changes to my production environment.
t
The regex matcher expects a string, not a regex
☝️ 1