One minute
Behat preg_match(): Compilation failed error
The other day while working on a project based with Symfony where acceptance tests are made with Behat I faced a pretty weird error hard to debug:
Warning: preg_match(): Compilation failed: two named subpatterns have the same name (PCRE2_DUPNAMES not set) at offset 219
I got this after adding a new Behat step like this:
@Then the JSON response node :jsonNode should be between :expectedMinValue and :expectedMaxValue
After trying many things I finally got a solution even though I don’t quite understand why happens. I guess it’s related to how Behat treats the variables internally so after specifying the type everything worked fine.
Here the solution:
@Then /^the JSON response node "([^"]*)" should be between (\d+) and (\d+)$/