Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pusher-js-mock

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pusher-js-mock

Mock Pusher.js in your JavaScript tests

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
34K
increased by9.44%
Maintainers
1
Weekly downloads
 
Created
Source

npm version Build Status Code Climate Test Coverage Open Source Helpers

pusher-js-mock logo

pusher-js-mock

Mock Pusher.js in your JavaScript tests with ease

Installing ⏬

Using yarn:

yarn add --dev pusher-js-mock

Or using npm:

npm install -D pusher-js-mock

Docs 📑

See project documentation for more reference.

Example usage 🏍

You can find basic usage of the library here. For more detailed examples, check out examples directory inside the project!

Using PusherMock to mock Pusher client instance

If you need to mock a Pusher object in your tests that can subscribe to channel, it's best to use PusherMock.

import { PusherMock } from "pusher-js-mock";

// initializing PusherMock
const pusher = new PusherMock()

// subscribing to a Pusher channel
const channel = pusher.subscribe("my-channel")

// emitting an event
channel.emit("event-name")
Using PusherFactoryMock to mock Pusher Factory

If you're attaching a PusherFactory to a window object like this:

window.PusherFactory = {
  pusherClient: function(pusherKey) {
    return new Pusher(pusherKey);
  }
};

It's best for you to use PusherFactoryMock.

import { PusherFactoryMock } from "pusher-js-mock";

// initialize instance of PusherFactoryMock
const pusherFactoryMock = new PusherFactoryMock();
// replace it with the object that is attached to a window
window.PusherFactory = pusherFactoryMock;

// get the Pusher client reference
pusher = pusherFactoryMock.pusherClient()

API 📦

Check out project docs on the information about API of the used classes.

Code of Conduct

Contributing

Credits

Photo by Octavian Rosca on Unsplash

Keywords

FAQs

Package last updated on 27 Nov 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc