-
-
Notifications
You must be signed in to change notification settings - Fork 771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix failing reset() on sandbox with unused fake server #1428
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the tests need a little love. I'm not sure what exactly though.
test/sandbox-test.js
Outdated
@@ -56,6 +56,18 @@ describe("sinonSandbox", function () { | |||
assert.same(sandbox.assert, sinonAssert); | |||
}); | |||
|
|||
it("can be reset without failing when pre-configured to use a fake server", function () { | |||
var sandbox = sinonSandbox.create({useFakeServer: true}); | |||
sandbox.reset(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no assertions in either test. How did this fail before your changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, good catch. I'll add some kind of refutation along with throws
(don't remember the exact api).
failing test
1) sinonSandbox can be reset without failing when configured to use a fake server:
TypeError: Cannot set property 'length' of undefined
at Object.resetBehavior (lib/sinon/util/fake_server.js:279:51)
at Object.reset (lib/sinon/util/fake_server.js:274:14)
at lib/sinon/collection.js:26:21
at Array.forEach (native)
at each (lib/sinon/collection.js:25:19)
at Object.reset (lib/sinon/collection.js:41:9)
at Context.<anonymous> (test/sandbox-test.js:68:17)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, pushed a fix. Output before fix:
1306 passing (846ms)
4 pending
2 failing
1) sinonSandbox can be reset without failing when pre-configured to use a fake server:
AssertionError: [refute.exception] Expected not to throw but threw TypeError (Cannot set property 'length' of undefined)
at referee.fail (node_modules/referee/lib/referee.js:193:25)
at Object.fail (node_modules/referee/lib/referee.js:90:21)
at assertion (node_modules/referee/lib/referee.js:98:21)
at Function.referee.(anonymous function).(anonymous function) [as exception] (node_modules/referee/lib/referee.js:118:23)
at Context.<anonymous> (test/sandbox-test.js:61:16)
2) sinonSandbox can be reset without failing when configured to use a fake server:
AssertionError: [refute.exception] Expected not to throw but threw TypeError (Cannot set property 'length' of undefined)
at referee.fail (node_modules/referee/lib/referee.js:193:25)
at Object.fail (node_modules/referee/lib/referee.js:90:21)
at assertion (node_modules/referee/lib/referee.js:98:21)
at Function.referee.(anonymous function).(anonymous function) [as exception] (node_modules/referee/lib/referee.js:118:23)
at Context.<anonymous> (test/sandbox-test.js:69:16)
874b9c1
to
0bf0a79
Compare
This has become part of |
Purpose (TL;DR) - mandatory
sandbox.reset()
fails when the sandbox has been configured to use a fake server and the server has not been utilized. This is the standard config forsinon-test
and was revealed to crash in sinonjs/sinon-test#57Background (Problem in detail) - optional
will crash immediately today due to the fields not being initalized.
Solution - optional
Initializes the fields at creation time.
How to verify - mandatory
npm install
git reset --hard HEAD~1 && npm test #pre-fix the tests fail
git merge && npm test #after fix the tests pass