require a module with mocked dependencies
This is not a mocking library. This module allows you to require a module and pass mocks for its dependencies.
Dependencies that are not passed will be solved normally.
npm install mockuire
Given a file like this one foo.js:
var path = require"path";return pathjoina b "burbujas";;
then we can test as follows:
var mockuire = require"mockuire"module;var mockedPath =return Arrayprototypeslicecallarguments 0join"!";foo = mockuire"./fixture/foo" path: mockedPathresult = foo "a" "b" ;testequal result "a!b!burbujas" ;
You have to pass the module in order to fallback to the module require when needed.
If your SUT is coffee script use this syntax:
var mockuire = require"mockuire"module "coffee": require"coffee-script" ;
where "coffee" is the extension and the next thing needs to have a compile function.