Mockery wraps a simple API around the hooking of 'require', to let you
provide mocks or substitute whole modules.
The job of Mockery is only hooking 'require' so you don't have to.
Thus you're free to use any (or no) mocking framework with Mockery,
and it's use is in no way limited to unit testing with mocks. If you
need to hook 'require' for some other purpose, Mockery will do the
job.
Read more at:
https://github.com/mfncooper/mockery
--
Martin Cooper
This is excellent stuff! Thanks for releasing it. It's the first tool I've been able to get working reliably for mocks. I've run into limitations with Gently and other libraries, but Mockery just works. Combined with Sinon, I finally have a usable mocking/stubbing setup that doesn't make me want to gouge my eyes out.
Regards,
Bryan
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
I didn't expect to be saving someone's eyesight by creating this, but
I'm glad to hear it's helpful. :-)
--
Martin Cooper
I did look at this, amongst others, before creating Mockery, and there
were a few things that I wanted to do differently. Easily handling
"nested" requires was one of them; if my source under test uses
rimraf, for example, I might want to just mock fs, and not rimraf per
se. Another was easily identifying the modules that are *not* mocked,
so that I'm always aware of anything my source under test is using
that it perhaps should not be using in a true unit test.
To each his own, though. While the two packages overlap in
functionality, I think each addresses a slightly different set of use
cases. I like that about the Node community; sharing ideas expressed
in packages, and avoiding the trappings of "one size fits all".
I did look at this, amongst others, before creating Mockery, and there
were a few things that I wanted to do differently. Easily handling
"nested" requires was one of them; if my source under test uses
rimraf, for example, I might want to just mock fs, and not rimraf per
se.
To each his own, though. While the two packages overlap in
functionality, I think each addresses a slightly different set of use
cases. I like that about the Node community; sharing ideas expressed
in packages, and avoiding the trappings of "one size fits all".