JSPM

fauxnix

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q17241F
  • License MIT

A fake websocket connection for Phoenix channels

Package Exports

  • fauxnix

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fauxnix) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Fauxnix

NOTE: Fauxnix is a new project and is likely to change.

Fauxnix is a mock websocket connection for receiving and responding to Phoenix channel messages and is heavily inspired by Pretender.

Usage

Fauxnix allows you to create a fake websocket connection and replace the returned object of new WebSocket() calls with the socket you passed in.

const socket = new Fauxnix(function() {
  this.receive("topic", "event", function() {
    return { status: "ok", response: { id: 1 } };
  });
});

Fauxnix.inject(socket);

Whenever socket receives a message from phoenix.js with a topic of "topic" and an event of "event" Fauxnix will send a reply with the given status and response in the return statement.

The call to Fauxnix.inject replaces the returned object of all new WebSocket() calls with the socket we defined.

The topic and event arguments also accept regular expressions.

Contributing

See the CONTRIBUTING document. Thank you, contributors!

License

Fauxnix is Copyright © 2015 thoughtbot. It is free software, and may be redistributed under the terms specified in the LICENSE file.

About thoughtbot

thoughtbot

Fauxnix is maintained and funded by thoughtbot, inc. The names and logos for thoughtbot are trademarks of thoughtbot, inc.

We love open source software! See our other projects or hire us to design, develop, and grow your product.