rewire
Advanced tools
Comparing version 4.0.1 to 5.0.0
Changelog | ||
--------- | ||
### 5.0.0 | ||
- **Breaking**: Remove Node v6 support. We had to do this because one of our dependencies had security issues and the version with the fix dropped Node v6 as well. | ||
- Update dependencies [#159](https://github.com/jhnns/rewire/pull/159) [#172](https://github.com/jhnns/rewire/issues/172) [#154](https://github.com/jhnns/rewire/issues/154) [#166](https://github.com/jhnns/rewire/issues/166) | ||
### 4.0.1 | ||
@@ -5,0 +9,0 @@ - Fix a bug where `const` was not properly detected [#139](https://github.com/jhnns/rewire/pull/139) |
@@ -45,3 +45,3 @@ "use strict"; | ||
// Test the regular expresssion at https://regex101.com/r/dvnZPv/2 and also check out testLib/constModule.js. | ||
matchConst = /(^|\s|\}|;)const(\/\*|\s)/gm, | ||
matchConst = /(^|\s|\}|;)const(\/\*|\s|{)/gm, | ||
nodeRequire, | ||
@@ -48,0 +48,0 @@ currentModule; |
{ | ||
"name": "rewire", | ||
"version": "4.0.1", | ||
"version": "5.0.0", | ||
"description": "Easy dependency injection for node.js unit testing", | ||
@@ -35,3 +35,4 @@ "keywords": [ | ||
"expect.js": "^0.3.1", | ||
"mocha": "^4.0.1" | ||
"mocha": "^7.1.0", | ||
"rewire": "file://." | ||
}, | ||
@@ -44,4 +45,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"eslint": "^4.19.1" | ||
"eslint": "^6.8.0" | ||
} | ||
} |
@@ -34,3 +34,3 @@ rewire | ||
```javascript | ||
// lib/myModules.js | ||
// lib/myModule.js | ||
// With rewire you can change all these variables | ||
@@ -37,0 +37,0 @@ var fs = require("fs"), |
@@ -12,2 +12,3 @@ const j = "j"; // At the beginning of the file | ||
const /*and this is also*/i = "i"; | ||
const{k} = {k: "k"}; | ||
@@ -44,1 +45,4 @@ exports.a = function () { | ||
}; | ||
exports.k = function () { | ||
return k; | ||
}; |
{ | ||
"main": "../../../lib/index.js" | ||
} |
@@ -180,3 +180,7 @@ // Don't run code in ES5 strict mode. | ||
it("should provide the ability to mock global objects just within the module", function () { | ||
// This test fails on modern Node versions since they started to configure some | ||
// global variables to be non-enumerable. This means that rewire() does in fact | ||
// modify the global console object in newer Node versions. | ||
// There is a work in progress fix at https://github.com/jhnns/rewire/tree/fix-globals | ||
it.skip("should provide the ability to mock global objects just within the module", function () { | ||
var rewiredModuleA = rewire("./moduleA.js"), | ||
@@ -392,6 +396,9 @@ rewiredModuleB = rewire("./moduleB.js"), | ||
var constModule = rewire("./constModule"); | ||
var varNames = Object.keys(constModule); | ||
"abcdefghij".split("").forEach(letter => { | ||
constModule.__set__(letter, "this has been changed"); // should not throw | ||
expect(constModule[letter]()).to.equal("this has been changed"); | ||
expect(varNames.length).to.be.greaterThan(0); | ||
varNames.forEach(varName => { | ||
constModule.__set__(varName, "this has been changed"); // should not throw | ||
expect(constModule[varName]()).to.equal("this has been changed"); | ||
}); | ||
@@ -398,0 +405,0 @@ }); |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
265008
96
5096
4
16
17
+ Added@babel/code-frame@7.24.7(transitive)
+ Added@babel/helper-validator-identifier@7.24.7(transitive)
+ Added@babel/highlight@7.24.7(transitive)
+ Addedacorn@7.4.1(transitive)
+ Addedacorn-jsx@5.3.2(transitive)
+ Addedajv@6.12.6(transitive)
+ Addedansi-escapes@4.3.2(transitive)
+ Addedansi-regex@4.1.15.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedastral-regex@1.0.0(transitive)
+ Addedcallsites@3.1.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedchardet@0.7.0(transitive)
+ Addedcli-cursor@3.1.0(transitive)
+ Addedcli-width@3.0.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcross-spawn@6.0.5(transitive)
+ Addeddebug@4.3.5(transitive)
+ Addeddoctrine@3.0.0(transitive)
+ Addedemoji-regex@7.0.38.0.0(transitive)
+ Addedeslint@6.8.0(transitive)
+ Addedeslint-scope@5.1.1(transitive)
+ Addedeslint-utils@1.4.3(transitive)
+ Addedespree@6.2.1(transitive)
+ Addedexternal-editor@3.1.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfigures@3.2.0(transitive)
+ Addedfile-entry-cache@5.0.1(transitive)
+ Addedflat-cache@2.0.1(transitive)
+ Addedflatted@2.0.2(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedglobals@12.4.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedignore@4.0.6(transitive)
+ Addedimport-fresh@3.3.0(transitive)
+ Addedinquirer@7.3.3(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addedms@2.1.2(transitive)
+ Addedmute-stream@0.0.8(transitive)
+ Addednice-try@1.0.5(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedparent-module@1.0.1(transitive)
+ Addedpath-key@2.0.1(transitive)
+ Addedpicocolors@1.0.1(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedregexpp@2.0.1(transitive)
+ Addedresolve-from@4.0.0(transitive)
+ Addedrestore-cursor@3.1.0(transitive)
+ Addedrxjs@6.6.7(transitive)
+ Addedsemver@6.3.1(transitive)
+ Addedslice-ansi@2.1.0(transitive)
+ Addedstring-width@3.1.04.2.3(transitive)
+ Addedstrip-ansi@5.2.06.0.1(transitive)
+ Addedstrip-json-comments@3.1.1(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedtable@5.4.6(transitive)
+ Addedtslib@1.14.1(transitive)
+ Addedtype-fest@0.21.30.8.1(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addedv8-compile-cache@2.4.0(transitive)
+ Addedwrite@1.0.3(transitive)
- Removedacorn@3.3.05.7.4(transitive)
- Removedacorn-jsx@3.0.1(transitive)
- Removedajv@5.5.2(transitive)
- Removedajv-keywords@2.1.1(transitive)
- Removedansi-escapes@3.2.0(transitive)
- Removedansi-regex@2.1.13.0.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedbabel-code-frame@6.26.0(transitive)
- Removedbuffer-from@1.1.2(transitive)
- Removedcaller-path@0.1.0(transitive)
- Removedcallsites@0.2.0(transitive)
- Removedchalk@1.1.3(transitive)
- Removedchardet@0.4.2(transitive)
- Removedcircular-json@0.3.3(transitive)
- Removedcli-cursor@2.1.0(transitive)
- Removedcli-width@2.2.1(transitive)
- Removedco@4.6.0(transitive)
- Removedconcat-stream@1.6.2(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedcross-spawn@5.1.0(transitive)
- Removeddebug@3.2.7(transitive)
- Removeddoctrine@2.1.0(transitive)
- Removedeslint@4.19.1(transitive)
- Removedeslint-scope@3.7.3(transitive)
- Removedespree@3.5.4(transitive)
- Removedexternal-editor@2.2.0(transitive)
- Removedfast-deep-equal@1.1.0(transitive)
- Removedfigures@2.0.0(transitive)
- Removedfile-entry-cache@2.0.0(transitive)
- Removedflat-cache@1.3.4(transitive)
- Removedglobals@11.12.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedignore@3.3.10(transitive)
- Removedinquirer@3.3.0(transitive)
- Removedis-resolvable@1.1.0(transitive)
- Removedisarray@1.0.0(transitive)
- Removedjs-tokens@3.0.2(transitive)
- Removedjson-schema-traverse@0.3.1(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedmimic-fn@1.2.0(transitive)
- Removedms@2.1.3(transitive)
- Removedmute-stream@0.0.7(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedonetime@2.0.1(transitive)
- Removedpath-is-inside@1.0.2(transitive)
- Removedpluralize@7.0.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedregexpp@1.1.0(transitive)
- Removedrequire-uncached@1.0.3(transitive)
- Removedresolve-from@1.0.1(transitive)
- Removedrestore-cursor@2.0.0(transitive)
- Removedrx-lite@4.0.8(transitive)
- Removedrx-lite-aggregates@4.0.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedslice-ansi@1.0.0(transitive)
- Removedstring-width@2.1.1(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedstrip-ansi@3.0.14.0.0(transitive)
- Removedstrip-json-comments@2.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedtable@4.0.2(transitive)
- Removedtypedarray@0.0.6(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedwrite@0.2.1(transitive)
- Removedyallist@2.1.2(transitive)
Updatedeslint@^6.8.0