GithubHelp home page GithubHelp logo

isabella232 / fauxnix Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thoughtbot/fauxnix

0.0 0.0 0.0 343 KB

A Fake Phoenix websocket connection for mocking channel responses.

License: MIT License

JavaScript 97.30% Shell 2.70%

fauxnix's Introduction

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(payload) {
    return { status: "ok", response: { id: payload.id } };
  });
});

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 payload from a message is passed in as the first argument to this.receives callback.

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.

fauxnix's People

Contributors

blakewilliams avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.