Files
cypress/packages/socket
Brian Mann af26fbebe6 feat: component testing (#14479)
Co-authored-by: Jessica Sachs <jess@jessicasachs.io>
Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
Co-authored-by: Zach Bloomquist <github@chary.us>
Co-authored-by: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Co-authored-by: ElevateBart <ledouxb@gmail.com>
Co-authored-by: Ben Kucera <14625260+Bkucera@users.noreply.github.com>
2021-02-04 15:45:16 -05:00
..
2021-02-04 15:45:16 -05:00
2021-02-04 15:45:16 -05:00
2021-02-04 15:45:16 -05:00
2021-02-04 15:45:16 -05:00
2021-02-04 15:45:16 -05:00
2021-02-04 15:45:16 -05:00

Socket

This is a shared lib for holding both the socket.io server and client.

Using

const socket = require("packages/socket")

// returns
{
  server: require("socket.io"),
  client: require("socket.io-client"),
  getPathToClientSource: function () {
    // returns path to the client 'socket.io.js' file
    // for use in the browser
  }
}
const socket = require("packages/socket")

// server usage
const srv = require("http").createServer()
const io = socket.server(srv)
io.on("connection", function(){})

// client usage
const client = socket.client("http://localhost:2020")
client.on("connect", function(){})
client.on("event", function(){})
client.on("disconnect", function(){})

// path usage
socket.getPathToClientSource()
// returns your/path/to/node_modules/socket.io-client/socket.io.js0

Testing

yarn workspace @packages/socket test