Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3436a7d

Browse files
author
Johannes
committed
updated docs
1 parent2c8949b commit3436a7d

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

‎README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ rewire does **not** load the file and eval the contents to emulate node's requir
1212

1313
**Debugging is fully supported.**
1414

15-
[![Build Status](https://secure.travis-ci.org/jhnns/rewire.png?branch=master)](http://travis-ci.org/jhnns/rewire)
15+
Furthermore rewire comes also with support for[browserify](https://github.com/substack/node-browserify). Thus you can mock your modules also in the browser.
1616

1717
<br />
1818

@@ -22,7 +22,16 @@ Installation
2222
`npm install rewire`
2323

2424
**For older node versions:**<br />
25-
rewire is tested with node 0.7.x. I recommend to run the unit tests via`mocha` in the rewire-folder before using rewire with older node versions.
25+
rewire is tested with node 0.6.x - 0.7.x. I recommend to run the unit tests via`mocha` in the rewire-folder before using rewire with older node versions.
26+
27+
**Use with[browserify](https://github.com/substack/node-browserify):**<br />
28+
29+
```javascript
30+
// debug=true splits the source in seperate files in chrome's developer inspector
31+
var b=require("browserify")({debug:true});
32+
33+
b.use(require("rewire").browserify);
34+
```
2635

2736
<br />
2837

@@ -34,8 +43,7 @@ var rewire = require("rewire");
3443

3544

3645
// rewire acts exactly like require.
37-
var myRewiredModule=rewire("../lib/myModule.js");
38-
myRewiredModule===require("../lib/myModule.js");// = true
46+
var myModule=rewire("../lib/myModule.js");
3947

4048

4149
// Your module will now export a special setter and getter for private variables.
@@ -67,8 +75,8 @@ myModule.__set__({
6775
});
6876

6977

70-
// You may also override globals. These changes are only within the module,
71-
//soyou don't have to beafraid that other modules are influenced by your mock.
78+
// You may also override globals. These changes are only within the module, so
79+
// you don't have to beconcerned that other modules are influenced by your mock.
7280
myModule.__set__({
7381
console: {
7482
log:function () {/* be quiet*/ }
@@ -91,6 +99,7 @@ assert.ok(myModule.__get__("currentState") === "idle");
9199

92100
// You can also disable caching when loading the rewired module. All
93101
// subsequent calls of require() will than return the original module again.
102+
rewire("./myModule.js")===require("./myModule.js");// = true
94103
rewire("./myModule.js",false)===require("./myModule.js");// = false
95104

96105

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp