Skip to content
Advertisement

jasmine partial string matching

I love the partial object matching that jasmine.objectContaining provides:

JavaScript

Is there a jasmine equivalent for strings? something along the lines of:

JavaScript

I’d like to look at a specific argument without resorting to assertions off mySpy.calls:

JavaScript

Advertisement

Answer

There isn’t anything of this sort in Jasmine. But you can leverage the ability of creating a custom matcher in Jasmine for this.

Here’s a small working example:

Your Factories

JavaScript

Your test case with a custom matcher

JavaScript

Hope this helps!

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement