Socket
Socket
Sign inDemoInstall

sinon

Package Overview
Dependencies
Maintainers
4
Versions
206
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sinon - npm Package Versions

1
1921

1.4.0

Diff

Changelog

Source

1.4.0

  • Argument matchers (Maximilian Antoni) sinon.match.{any, same, typeOf, instanceOf, has, hasOwn, defined, truthy, falsy} as well as typeOf shortcuts for boolean, number, string, object, function, array, regexp and date. The result of a call can be used with spy.calledWith.
  • spy.returned now works with matchers and compares objects deeply.
  • Matcher assertions: calledWithMatch, alwaysCalledWithMatch and neverCalledWithMatch
  • calledWithNew and alwaysCalledWithNew for assert (Maximilian Antoni)
  • Easier stubbed fluent interfaces: stub.returnsThis() (Glen Mailer)
  • allow yields() and family to be used along with returns()/throws() and family (Glen Mailer)
  • Async versions callsArg* and yields* for stubs (TEHEK)
  • Format args when doing spy.printf("%*") (Domenic Denicola)
  • Add notCalled property to spies
  • Fix: spy.reset did not reset fakes created by spy.withArgs (Maximilian Antoni)
  • Properly restore stubs when stubbing entire objects through the sandbox (Konrad Holowinski)
  • Restore global methods properly - delete properties that where not own properties (Keith Cirkel)
  • setTimeout and setInterval pass arguments (Rodion Vynnychenko)
  • Timer callbacks that contain a clock.tick no longer fails (Wesley Waser)
  • spy(undefined, "property") now throws
  • Prevent multiple restore for fake timers (Kevin Decker)
  • Fix toString format under Node (Kevin Decker)
  • Mock expectations emit success and failure events (Kevin Decker)
  • Development improvement: Use Buster.JS to test Sinon
  • Fix bug where expect.atLeast failed when minimum calls where received
  • Make fake server safe to load on node.js
  • Add support for no args on .withArgs and .withExactArgs (Tek Nynja)
  • Avoid hasOwnProperty for host objects
cjohansen
published 1.3.4 •

cjohansen
published 1.3.3 •

cjohansen
published 1.3.2 •

Changelog

Source

1.3.2

  • Stronger Node inference in sandbox
  • Fixed issue with sinon.useFakeTimers() and Rhino.js 1.7R3
  • Formatting brush-up
  • FIX Internet Explorer misreporting the type of Function objects originating in an external window as "object" instead of "function".
  • New methods stub.callsArgOn, stub.callsArgOnWith, stub.yieldsOn, stub.yieldsToOn
  • Implemented
  • Fixing clearTimeout to not throw when called for nonexistent IDs.
  • Spys that are created using 'withArgs' now get initialized with previous calls to the original spy.
  • Minor bug fixes and docs cleanup.
cjohansen
published 1.3.1 •

Changelog

Source

1.3.1

  • Fix bug in core sinon: isNode was used for both a variable and a function, causing load errors and lots of bugs. Should have never left the door.
cjohansen
published 1.3.0 •

Changelog

Source

1.3.0

  • Support using bare functions as fake server response handlers (< 1.3.0 required URL and/or method matcher too)

  • Log some internal errors to sinon.log (defaults to noop). Set sinon.log to your logging utility of choice for better feedback when.

  • White-list fake XHRs: Allows some fake requests and some that fall through to the backend server (Tim Ruffles)

  • Decide Date.now support at fake-time. Makes it possible to load something that polyfills Date.now after Sinon loaded and still have Date.now on fake Dates.

  • Mirror properties on replaced function properties

  • New methods: spy.yield(), spy.yieldTo(), spy.callArg() and spy.callArgWith() can be used to invoke callbacks passed to spies (while avoiding the mock-like upfront yields() and friends). invokeCallback is available as an alias for yield for people working with strict mode. (Maximilian Antoni)

  • New properties: spy.firstCall, spy.secondCall, spy.thirdCall and spy.lastCall. (Maximilian Antoni)

  • New method: stub.returnsArg(), causes stub to return one of its arguments. (Gavin Huang)

  • Stubs now work for inherited methods. This was previously prohibited to avoid stubbing not-yet-implemented methods. (Felix Geisendörfer)

  • server.respond() can now accept the same arguments as server.respondWith() for quick-and-dirty respondWith+respond. (Gavin Huang)

  • Format objects with buster-format in the default bundle. Default to util.inspect on node unless buster-format is available (not a hard dependency, more like a 'preference').

  • Bug fix: Make sure XHRs can complete even if onreadystatechange handler fails

  • Bug fix: Mirror entire Date.prototype, including toUTCString when faking

  • Bug fix: Default this object to global in exposed asserts

  • Bug fix: sinon.test: use try/finally instead of catch and throw - preserves stack traces (Kevin Turner)

  • Bug fix: Fake setTimeout now returns ids greater than 0. (Domenic Denicola)

  • Bug fix: NPM install warning (Felix Geisendörfer)

  • Bug fix: Fake timers no longer swallows exceptions (Felix Geisendörfer)

  • Bug fix: Properly expose all needed asserts for node

  • Bug fix: wrapMethod on window property (i.e. when stubbing/spying on global functions)

  • Bug fix: Quote "yield" (Ben Hockey)

  • Bug fix: callOrder works correctly when spies have been called multiple times

published 1.2.0 •

Changelog

Source

1.2.0

  • Bug fix: abort() switches state to DONE when OPENED and sent. Fix by Tristan Koch.
  • Bug fix: Mootools uses MSXML2.XMLHTTP as objectId, which Sinon matched with different casing. Fix by Olmo Maldonado.
  • Bug fix: When wrapping a non-owned property, restore now removes the wrapper instead of replacing it. Fix by Will Butler.
  • Bug fix: Make it possibly to stub Array.prototype.push by not using that method directly inside Sinon.
  • Bug fix: Don't assume that req.requestBody is a string in the fake server.
  • Added spy.printf(format) to print a nicely formatted message with details about a spy.
  • Garbage collection: removing fakes from collections when restoring the original methods. Fix by Tristan Koch.
  • Add spy.calledWithNew to check if a function was used as a constructor
  • Add spy.notCalledWith(), spy.neverCalledWith() and sinon.assert.neverCalledWith. By Max Antoni
  • Publicly expose sinon.expectation.fail to allow tools to integrate with mock expectations.
  • Fake XMLHttpRequests now support a minimal portion of the events API, making them work seamlessly with e.g. SproutCode (which uses xhr.addEventListener("readystatechange"). Partially by Sven Fuchs.
published 1.1.1 •

Changelog

Source

1.1.1

  • Fix broken mock verification in CommonJS when not including the full Sinon package.
published 1.1.0 •

Changelog

Source

1.1.0

  • The fake server now has a autoRespond method which allows it to respond to requests on the fly (asynchronously), making it a good fit for mockup development
  • Stubs and spies now has a withArgs method. Using it allows you to create several spies/stubs for the same method, filtered by received arguments
  • Stubs now has yields and yieldsTo methods for fuzzily invoking callbacks. They work like callsArgAt only by inferring what callback to invoke, and yieldsTo can invoke callbacks in object "options" arguments.
  • Allow sandboxes/collections to stub any property so long as the object has the property as an own property
  • Significantly improve error reporting from failed mock expectations. Now prints all met and unmet expectations with expected and received arguments
  • Allow mock expectations to be consumed in any order
  • Add pretty printing of all calls when assertions fail
  • Fix bug: Stub exception message ended up as "undefined" (string) if not specified
  • Pass capture groups in URLs to fakeServer function handlers
  • Pass through return value from test function in testCase
  • typeof require is not enough to assume node, also use typeof module
  • Don't use Object.create in sinon.create. In the off chance that someone stubs it, sinon will fail mysteriously (Thanks to Espen Dalløkken)
  • Catch exceptions when parsing DOM elements "on a hunch" When responding to XHRs, Sinon acts like most browsers and try to parse the response into responseXML if Content-Type indicates XML or HTML. However, it also does this if the type is not set. Obviously, this may misfire and should be caught.
  • Fix fakeServer.respond() to not drop requests when they are queued during the processing of an existing queue. (Sven Fuchs)
  • Clean up module loading in CommonJS environments (Node.js still the only tested such environment). No longer (temporarily) modifies require.paths, always loads all modules.
published 1.0.2 •

Changelog

Source

1.0.2

  • Fix JSON bug in package.json
  • Sandbox no longer tries to use a fake server if config says so, but server is not loaded
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc