Socket
Socket
Sign inDemoInstall

nise

Package Overview
Dependencies
6
Maintainers
4
Versions
55
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

nise

Fake XHR and server


Version published
Maintainers
4
Weekly downloads
4,512,536
decreased by-15.72%

Weekly downloads

Package description

What is nise?

The nise npm package is a library for creating fake servers, responses, and timers in JavaScript tests. It allows developers to simulate server responses and time-based behavior without the need for an actual server or waiting for real time to pass. This is particularly useful in unit testing, where tests need to be both fast and deterministic.

What are nise's main functionalities?

Fake XMLHttpRequest and server

This feature allows you to create a fake server that can respond to XMLHttpRequests. You can specify the HTTP method, URL, and response details. This is useful for testing AJAX requests without needing to hit a real server.

var fakeServer = nise.fakeServer.create();
fakeServer.respondWith('GET', '/some/article', [200, { 'Content-Type': 'application/json' }, '{ "id": 12, "comment": "Hey there" }']);
fakeServer.respondImmediately = true;

Fake timers

With fake timers, you can simulate the passage of time in tests. This is useful for functions that rely on setTimeout, setInterval, or Date objects. It allows you to test time-dependent code without real time delays.

var clock = nise.useFakeTimers();
clock.tick(1000); // Simulate the passage of 1 second

Other packages similar to nise

Readme

Source

nise (偽)

npm version codecov Contributor Covenant

fake XHR and Server

Documentation: http://sinonjs.github.io/nise/

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Sponsors

Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]

Licence

nise was released under BSD-3

Keywords

FAQs

Last updated on 31 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc