Comments (5)
Hi @YasharF, thanks for reporting this.
Would you like to send a PR? I think changing the devDependencies
and peerDependencies
from 2.1 - 4
to 2.1 - 5
would be enough.
from sinon-mongoose.
sure
It looks like that npm audit
is tagging a bunch of packages with issues, so I'll bump a few more packages while updating package.json:
found 26 vulnerabilities (5 low, 11 moderate, 10 high) in 3047 scanned packages
run `npm audit fix` to fix 4 of them.
16 vulnerabilities require semver-major dependency updates.
6 vulnerabilities require manual review. See the full report for details.
from sinon-mongoose.
sinon 5 is not the latest. 6 is supposed to be backward compatible with sinon 5. My first attempt to upgrade sinon-mongoose to use sinon 6 is causing two of the tests to fail.
$ git diff package.json
diff --git a/package.json b/package.json
index 97cf3bf..b8a1a5f 100644
--- a/package.json
+++ b/package.json
@@ -39,10 +39,10 @@
"gulp-plumber": "^1.2.0",
"isparta": "^4.0.0",
"mongoose": "^4.2.5",
- "sinon": "2.1 - 4"
+ "sinon": "2.1 - 6"
},
"peerDependencies": {
- "sinon": "2.1 - 4"
+ "sinon": "2.1 - 6"
},
"scripts": {
"prepublishOnly": "gulp prepublishOnly",
$ npm test
> [email protected] test /mnt/c/temp/sinon-mongoose
> gulp
[19:16:44] Using gulpfile /mnt/c/temp/sinon-mongoose/gulpfile.js
[19:16:45] Starting 'static'...
[19:16:45] Starting 'pre-test'...
[19:16:48] Finished 'pre-test' after 3.22 s
[19:16:48] Starting 'test'...
`sandbox.create()` is deprecated. Use default sandbox at `sinon.sandbox` or create new sandboxes with `sinon.createSandbox()`
sinon-mongoose
should made Mongoose model methods chainables
✓ #find (46ms)
✓ #lean
✓ #count
✓ #aggregate
should made Mongoose document methods chainables
✓ #update
✓ #verify chained
using sinon sandbox
1) should work mocking Model
2) "after each" hook for "should work mocking Model"
6 passing (172ms)
2 failing
1) sinon-mongoose
using sinon sandbox
should work mocking Model:
TypeError: BookMock.expects(...).withArgs(...).chain is not a function
at Context.<anonymous> (test/index.js:116:59)
2) sinon-mongoose
using sinon sandbox
"after each" hook for "should work mocking Model":
ExpectationError: Expected find(SOME_ARGUMENTS[, ...]) once (never called)
at Object.fail (node_modules/sinon/lib/sinon/mock-expectation.js:281:25)
at Object.verify (node_modules/sinon/lib/sinon/mock.js:108:29)
at node_modules/sinon/lib/sinon/sandbox.js:32:21
at Array.filter (<anonymous>)
at applyOnEach (node_modules/sinon/lib/sinon/sandbox.js:31:13)
at Sandbox.verify (node_modules/sinon/lib/sinon/sandbox.js:340:9)
at Context.<anonymous> (test/index.js:109:15)
-----------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
-----------|----------|----------|----------|----------|----------------|
lib/ | 12.2 | 0 | 0 | 12.2 | |
index.js | 12.2 | 0 | 0 | 12.2 |... 59,60,63,66 |
-----------|----------|----------|----------|----------|----------------|
All files | 12.2 | 0 | 0 | 12.2 | |
-----------|----------|----------|----------|----------|----------------|
=============================== Coverage summary ===============================
Statements : 12.2% ( 5/41 )
Branches : 0% ( 0/18 )
Functions : 0% ( 0/8 )
Lines : 12.2% ( 5/41 )
================================================================================
[19:17:00] 'test' errored after 12 s
[19:17:00] Error in plugin "gulp-mocha"
Message:
Command failed: mocha /mnt/c/temp/sinon-mongoose/test/index.js --colors --reporter=spec
`sandbox.create()` is deprecated. Use default sandbox at `sinon.sandbox` or create new sandboxes with `sinon.createSandbox()`
sinon-mongoose
should made Mongoose model methods chainables
✓ #find (46ms)
✓ #lean
✓ #count
✓ #aggregate
should made Mongoose document methods chainables
✓ #update
✓ #verify chained
using sinon sandbox
1) should work mocking Model
2) "after each" hook for "should work mocking Model"
6 passing (172ms)
2 failing
1) sinon-mongoose
using sinon sandbox
should work mocking Model:
TypeError: BookMock.expects(...).withArgs(...).chain is not a function
at Context.<anonymous> (test/index.js:116:59)
2) sinon-mongoose
using sinon sandbox
"after each" hook for "should work mocking Model":
ExpectationError: Expected find(SOME_ARGUMENTS[, ...]) once (never called)
at Object.fail (node_modules/sinon/lib/sinon/mock-expectation.js:281:25)
at Object.verify (node_modules/sinon/lib/sinon/mock.js:108:29)
at node_modules/sinon/lib/sinon/sandbox.js:32:21
at Array.filter (<anonymous>)
at applyOnEach (node_modules/sinon/lib/sinon/sandbox.js:31:13)
at Sandbox.verify (node_modules/sinon/lib/sinon/sandbox.js:340:9)
at Context.<anonymous> (test/index.js:109:15)
Details:
code: 2
killed: false
stdout: `sandbox.create()` is deprecated. Use default sandbox at `sinon.sandbox` or create new sandboxes with `sinon.createSandbox()`
sinon-mongoose
should made Mongoose model methods chainables
✓ #find (46ms)
✓ #lean
✓ #count
✓ #aggregate
should made Mongoose document methods chainables
✓ #update
✓ #verify chained
using sinon sandbox
1) should work mocking Model
2) "after each" hook for "should work mocking Model"
6 passing (172ms)
2 failing
1) sinon-mongoose
using sinon sandbox
should work mocking Model:
TypeError: BookMock.expects(...).withArgs(...).chain is not a function
at Context.<anonymous> (test/index.js:116:59)
2) sinon-mongoose
using sinon sandbox
"after each" hook for "should work mocking Model":
ExpectationError: Expected find(SOME_ARGUMENTS[, ...]) once (never called)
at Object.fail (node_modules/sinon/lib/sinon/mock-expectation.js:281:25)
at Object.verify (node_modules/sinon/lib/sinon/mock.js:108:29)
at node_modules/sinon/lib/sinon/sandbox.js:32:21
at Array.filter (<anonymous>)
at applyOnEach (node_modules/sinon/lib/sinon/sandbox.js:31:13)
at Sandbox.verify (node_modules/sinon/lib/sinon/sandbox.js:340:9)
at Context.<anonymous> (test/index.js:109:15)
stderr:
failed: true
signal: null
cmd: mocha /mnt/c/temp/sinon-mongoose/test/index.js --colors --reporter=spec
timedOut: false
[19:17:38] Finished 'static' after 54 s
npm ERR! Test failed. See above for more details.
from sinon-mongoose.
The scope of adding sinon 5 and 6 seem to be a breaking change and I think I need help with someone else taking over the change. I was able to help upgrade a bunch of other packages while looking at the sinon upgrade though.
from sinon-mongoose.
Indeed, it looks there's a breaking change. I'll take a look later today and see if I can solve that issue.
Thanks for all the info! 😉
from sinon-mongoose.
Related Issues (20)
- Feature Request - Handle MongooseModel.method().cursor() streams HOT 3
- How to mock virtuals HOT 2
- .expects(...).chain is not a function HOT 2
- how to mock mongoose aggregate functions using sinon or sinon-mongoose HOT 1
- TypeError: Attempted to wrap undefined property execPopulate as function HOT 2
- Update sinon peer dependency? HOT 1
- Chain fn does not work properly HOT 2
- TypeError: Attempted to wrap undefined property aggregate as function HOT 2
- Problems on chaining count with where in array plus limit HOT 5
- Remove dependency on gulp-nsp HOT 1
- Remove dependency on gulp-util due to deprecation HOT 2
- Not compatible with [email protected] createSandbox (chain is not a function) HOT 4
- Failing tests HOT 2
- Removal of unmaintained dependencies HOT 3
- Upgrade of mongoose to +5.5.x HOT 5
- Cannot read property '$handleCallbackError' of undefined
- Readme.md outdated
- Not compatible with Sinon 8.x HOT 14
- Cannot chain existing mongoose query object HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sinon-mongoose.