https://github.com/skrivle/mock-loader
Webpack mock loader
https://github.com/skrivle/mock-loader
amd-modules javascript mock webpack
Last synced: about 1 year ago
JSON representation
Webpack mock loader
- Host: GitHub
- URL: https://github.com/skrivle/mock-loader
- Owner: skrivle
- Created: 2015-11-27T08:30:14.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-05-26T12:46:13.000Z (almost 9 years ago)
- Last Synced: 2025-03-02T19:17:37.638Z (about 1 year ago)
- Topics: amd-modules, javascript, mock, webpack
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Mock loader (WIP)
Webpack mock loader for AMD modules only.
Inspired by [proxy-loader](https://github.com/c-dante/proxy-loader) and
[inject-loader](https://github.com/plasticine/inject-loader) but since they
both lack descent support for AMD modules, this module was created.
## Usage
Once a module is loaded with the mock loader an injector function will be
returned instead of the original module. This function can be used to mock the
original dependencies of the loaded module. The injector accepts an object with
dependency paths as keys and mock objects as values. If a given dependency is omitted
the original dependency will be loaded automatically.
```javascript
define(
[
'mock!./myModule'
],
function (
myModuleInjector
) {
var myMock = {
method: function () {
return true;
}
};
var myModule = myModuleInjector({
'path/to/original/dep': myMock
});
});
```