diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -139,9 +139,6 @@ myModule.__with__({ Limitations ----------- -**Using `const`**<br> -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**<br> 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. |