Testing - adding custom matchers

871 views
Skip to first unread message

darren.b...@gmail.com

unread,
Aug 22, 2012, 4:50:54 PM8/22/12
to ang...@googlegroups.com
Hi all

Using angular-seed as a base I'm trying to add a custom matcher in a test using something similar to:
beforeEach(function () {
    this.addMatchers({
        toBeOkAlways:function () {
            return true;
        }
    });
});

However, when I run it I get the error:
TypeError: Object #<Object> has no method 'addMatchers'

Can anyone advise on what I'm doing wrong?

Thanks
Darren

Pawel Kozlowski

unread,
Aug 22, 2012, 4:55:02 PM8/22/12
to ang...@googlegroups.com
Hi Darren!

This works for me: http://jsfiddle.net/pkozlowski_opensource/ztAFx/2/
Could you try to change / extend this jsFiddle to expose your issue?

Cheers,
Pawel
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To post to this group, send email to ang...@googlegroups.com.
> To unsubscribe from this group, send email to
> angular+u...@googlegroups.com.
> Visit this group at http://groups.google.com/group/angular?hl=en.
>
>

darren.b...@gmail.com

unread,
Aug 23, 2012, 2:24:29 PM8/23/12
to ang...@googlegroups.com
Hi Pawal

Thanks for your prompt reply but I've figured out what I was doing wrong. I'm using angular-scenario and I thought it was using straight jasmine.

For those facing the same problem, in scenario you add matchers using the following syntax:

angular.scenario.matcher("toBeOkAlways", function () {
    return true;
});


Still finding my way...

Cheers
Darren

pir...@gmail.com

unread,
Feb 10, 2013, 1:33:22 PM2/10/13
to ang...@googlegroups.com, darren.b...@gmail.com
I also stumbled across this solution to a problem.

Is this the recommended way of getting in new matchers?

Also, you can only do this before your first spec, so it's not super flexible.

-P.

Elliott Sprehn

unread,
Feb 11, 2013, 11:20:04 PM2/11/13
to ang...@googlegroups.com, darren.b...@gmail.com
Yeah, this is a limitation of the design of the scenario runner. I don't think it would be too hard to fix if someone was feeling ambitious.



To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages