Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add window.jsbundleMocks

  • Loading branch information...
commit 5aff74f22018d465f670ebad03149fb8fe630431 1 parent 9007edf
@paulbaumgart paulbaumgart authored
Showing with 17 additions and 2 deletions.
  1. +15 −0 README.md
  2. +1 −1  package.json
  3. +1 −1  tmpl/bundle.tmpl
View
15 README.md
@@ -130,6 +130,21 @@ In order to make unit testing your modules easier, jsbundle provides a mocking A
* <code>module.unmock(moduleIdSubstring)</code> disables a previous call to <code>module.mock</code>. The *moduleIdSubstring* must match the one from the corresponding <code>module.mock</code> call exactly.
+For integration testing, you'll want to define mocks before loading the bundle by using the global variable <code>jsbundleMocks</code>:
+
+ <script>
+ window.jsbundleMocks = {
+ 'some-module-name.js', { my: 'mock module.exports object' }
+ };
+ </script>
+ <script src="/path/to/my/bundle.js"></script>
+
+You can still <code>module.unmock</code> later on in your test code:
+
+ module.unmock('some-module-name.js');
+
+Again, make sure the strings match exactly.
+
### devcdn
[JSBUNDLE_ENV=<env>] devcdn [port]
View
2  package.json
@@ -3,7 +3,7 @@
"name": "jsbundle",
"description": "Simple, clean, and automatic bundling of your Node modules and packages for use in the browser.",
"keywords": "browser require bundle module package static-analysis",
- "version": "0.16.1",
+ "version": "0.16.2",
"repository": {
"type": "git",
"url": "git://github.com/proxv/jsbundle.git"
View
2  tmpl/bundle.tmpl
@@ -3,7 +3,7 @@
var _$_modules = {};
var _$_mainModuleId = @mainModuleId;
var _$_moduleMap = @moduleMap;
- var _$_mockedModules;
+ var _$_mockedModules = self.jsbundleMocks;
var _$_hasOwnProp = Object.prototype.hasOwnProperty;
function _$_mock(idSubstring, mockExports) {
Please sign in to comment.
Something went wrong with that request. Please try again.