Sinon.JS
Standalone test spies, stubs, and mocks for JavaScript
Acerca de Sinon.JS
Sinon.JS is a powerful testing framework that works with any unit testing framework. It provides tools like spies, stubs, and mocks to simplify testing JavaScript applications. Whether you're testing callbacks, Ajax requests, or time-sensitive logic, Sinon.JS offers flexible solutions to isolate and verify behavior without complex setup.
Preguntas frecuentes
You can install Sinon.JS using npm by running the command: npm install sinon.
For Node and CommonJS build systems, you can require Sinon using: var sinon = require("sinon"); For direct browser use, include the script: . For ES6 Modules, use: import sinon from "./node_modules/sinon/pkg/sinon-esm.js"; .
Sinon.JS provides fake timers to test time-sensitive logic. You can use sinon.useFakeTimers() to create a clock and sinon.restore() to restore the original timers after your test.
You can use sinon.replace() to replace the jQuery.ajax method with a fake in your test. After your test, restore the original method using sinon.restore().
You can get help by joining the discussion on Stack Overflow or visiting the IRC channel #sinon.js on freenode.
Yes, Sinon.JS is released under the BSD license, which means it is free to use.
Alternativas a considerar
Ver todas las alternativasInsignias
Promociona Sinon.JS y dale más visibilidad añadiendo estas insignias a tu web, documentación o ficha de producto. Cada insignia enlaza a la página de Sinon.JS en Webfolio.
<a href="https://www.webfolio.to/tools/sinon-js?utm_source=badge&utm_campaign=badge" target="_blank" rel="noopener noreferrer"><img src="https://www.webfolio.to/badges/featured_color.svg" alt="Destacado en Webfolio" style="max-width: 150px" /></a>
Categorías
Reclamar esta herramienta
¿Eres el fundador? Reclama tu perfil para actualizar los detalles y rastrear visualizaciones.