I noticed that when I formulate a Jasmine Expect using toMatch
and the string that is being match contains (
it will fail. Has anyone else noticed this? If so what did you do?
Example
This fails or returns "False" when it should return "True"
expect("test (test) with other stuff").toMatch("test (test)");
This passes and returns "True"
expect("test %test% with other stuff").toMatch("test %test%");
toMatch()
is used for regular expression matches. Parenthesis have a special meaning (they are used for capturing/saving groups) in regular expressions, you need to escape them if you want them to be treated as normal parenthesis:
expect("test (test) with other stuff").toMatch("test \(test\)");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With