Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jasmine Expect toMatch and Parentheses

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%");
like image 712
JoatMon Avatar asked Sep 11 '14 22:09

JoatMon


1 Answers

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\)");
like image 172
alecxe Avatar answered Oct 21 '22 01:10

alecxe