Files
cypress/packages/socket
Blue F 8ff38cdb01 feat: Create public Cypress.ensure API for use with custom queries (#24697)
* fix: Improve TypeScript support for custom queries

* Typo fix

* Fix TS more

* Move 'ensures' off of cy and onto Cypress

* Type fixes

* One missed replacement

* Test fixes

* Properly pass in  to ensureRunnable

* Add .eslintignores to quiet down warnings

* Review feedback

* Update cli/types/cypress.d.ts

Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>

Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
2022-11-29 09:34:34 -06: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"),
  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 } = require("@packages/socket/lib/client")
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