
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
cypress-websocket-server
Advanced tools
Cypress plugin to mock a websocket server during tests.
Install:
npm i cypress-websocket-server
Add cy.setWebsocketWorkflow()
command by adding the following to cypress/support/index.js
:
import { addCommand } from "cypress-websocket-server";
addCommand();
Add websocket server in cypress/plugins/index.js
, accessible via endpoint ws://localhost:1999
:
const { startMockWsServer } = require("cypress-websocket-server");
module.exports = (on, config) => {
startMockWsServer(config);
};
The fixture .json
file should contain an array of objects with properties:
type
:
server
: a message that should be sent by the serverclient
: a message the server expects from the clientreconnect
: an expected client reconnectionpayload
(optional): message data, can be of any object typeIn a scenario where a websocket exchange is expected after the user clicking a button, the websocket can be configured to follow a specific workflow like this:
describe("Trigger WS workflow on button click", () => {
it("Run new project", () => {
cy.visit("/");
cy.setWebsocketWorkflow("expected-workflow.json");
cy.get("[data-cy=ws-trigger-button]").click();
});
});
Being the content of expected-workflow.json
, in fixtures folder:
[
{
"type": "server",
"payload": { "message": "connected" }
},
{
"type": "client",
"payload": { "action": "get-user" }
},
{
"type": "server",
"payload": {
"message": "user-info",
"data": {
"id": 1,
"name": "My User"
}
}
}
]
The server will listen to any connections in ws://localhost:1999
and:
{ "message": "connected" }
on client connection{ "action": "get-user" }
If the client doesn't send the expected message in the right order, or send additional messages, an error will be printed to Cypress console.
FAQs
Cypress plugin to mock a websocket server during tests
We found that cypress-websocket-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.