From c176d025b57ff616d2a63989a685fe70651e33d3 Mon Sep 17 00:00:00 2001 From: Jeroen Valcke Date: Fri, 20 Oct 2017 20:06:42 +0200 Subject: Update README --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index da42d46..03b2866 100644 --- a/README.md +++ b/README.md @@ -139,9 +139,6 @@ myModule.__with__({ Limitations ----------- -**Using `const`**
-It's not possible to rewire `const` (see [#79](https://github.com/jhnns/rewire/issues/79)). This can probably be solved with [proxies](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Proxy) someday but requires further research. - **Transpilers**
Some transpilers, like babel, rename variables in order to emulate certain language features. Rewire will not work in these cases (see [#62](https://github.com/jhnns/rewire/issues/62)). A possible solution might be switching to [babel-plugin-rewire](https://github.com/speedskater/babel-plugin-rewire). @@ -182,10 +179,15 @@ Please be aware that you can't rewire `eval()` or the global object itself. API --- -### rewire(filename: String): rewiredModule +### rewire(filename: String, [options]): rewiredModule Returns a rewired version of the module found at `filename`. Use `rewire()` exactly like `require()`. +#### Options +| Property | Default | Description | +|----------|---------|-------------| +| convertConst | false | Set to true to convert all `const` variables of the required module to `let`. This way you can mock const variables. **Caution**: Setting this to true can lead to inaccurate tests. + ### rewiredModule.__set__(name: String, value: *): Function Sets the internal variable `name` to the given `value`. Returns a function which can be called to revert the change. -- cgit v1.2.3