Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/rewire.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ewald <johannes.ewald@peerigon.com>2016-03-16 04:15:17 +0300
committerJohannes Ewald <johannes.ewald@peerigon.com>2016-03-16 04:15:17 +0300
commitf126dcbe4c97e695ffc2e3de0cfe0a8c32f66fc5 (patch)
treef1064dfe3e7b1713b9c2d2dcf8fbed46de2ee737 /README.md
parent447f38319e2b8256c57c7ea220badbcd00a31c1c (diff)
Add note on imported globals in README
See http://stackoverflow.com/questions/34885024/when-using-rewire-and-sinon-faketimer-order-matters/36025128 Fixes #87
Diffstat (limited to 'README.md')
-rw-r--r--README.md3
1 files changed, 3 insertions, 0 deletions
diff --git a/README.md b/README.md
index 233d4c3..da42d46 100644
--- a/README.md
+++ b/README.md
@@ -216,6 +216,9 @@ rewire("./myModule.js") === rewire("./myModule.js"); // = false
This can especially be a problem if the module is not idempotent [like mongoose models](https://github.com/jhnns/rewire/issues/27).
+**Globals are imported into the module's scope at the time of rewiring**<br>
+Since rewire imports all gobals into the module's scope at the time of rewiring, property changes on the `global` object after that are not recognized anymore. This is a [problem when using sinon's fake timers *after* you've called `rewire()`](http://stackoverflow.com/questions/34885024/when-using-rewire-and-sinon-faketimer-order-matters/36025128).
+
**Dot notation**<br>
Although it is possible to use dot notation when calling `__set__`, it is strongly discouraged in most cases. For instance, writing `myModule.__set__("console.log", fn)` is effectively the same as just writing `console.log = fn`. It would be better to write: