Closed JJ-Kamminga closed 1 year ago
The documentation for matching a route shows that the argument can either be a string (with glob matching support) or a regex expression. You are passing in a string and expecting it to be converted into a regex for you which we do not support (there is no straightforward way to determine if the string you passed is a regex or just a plain ol' string).
We could possibly change the UI of the route matcher to make a visual distinction between a string and regex (color, quotes around the string etc...) as this would have helped you debug your issue faster. I can get this routed to our feature request list for consideration.
Going to close this issue, if you think the UI enhancement would be beneficial please leave a comment and I can get this officially routed to the feature list.
Oops, think I missed the notification for your previous reply. Apologies!
I suppose it is in the documentation indeed, but your explanation helps a lot to explain why.
For me, the visual change you suggest would indeed be beneficial. But I cannot say of course for how many people this is the case and if that is worth the effort.
Current behavior
When I try to use a routematcher with a valid RegExp with template literals, , it doesn't work.
When I use the RegExp constructor, it does work.
In the Cypress Routes overview table, the 2 show up exactly the same in the Route Matcher column (this makes it hard to debug why it doesn't work for a user!).
Desired behavior
I would like to be able to use RegExp literal with template literals as route matcher in cy.intercept().
To be clear, there are good workarounds as I described in "Current behavior".
However, I spent a considerable amount of time debugging (and reading the documentation) why my routematcher did not work. I would like to save others the time.
Test code to reproduce
Cypress Version
11.2.0
Node version
18.8.0
Operating System
macOS 13.1
Debug Logs