websocket-server-testing
v0.0.1
Published
Testing framework for distributed websocket server
Maintainers
Readme
Distributed WebSocket Testing
A TypeScript-based npm package to run test cases for distributed WebSocket servers. This tool helps in load testing, connection stability checks, and real-time message validation across multiple WebSocket instances.
Features
- Simulate multiple WebSocket clients.
- Send and receive messages in real-time.
- Validate server responses.
- Support for distributed WebSocket environments.
- Customizable test scripts.
- Detailed logs and metrics.
Installation
npm install distributed-websocket-test-runner --save-devor with yarn:
yarn add distributed-websocket-test-runner --devUsage
Basic Example
import { WebSocketTestRunner } from 'distributed-websocket-test-runner';
const runner = new WebSocketTestRunner({
servers: [
'ws://localhost:8080',
'ws://localhost:9090'
],
clients: 100, // Number of simulated clients
testCases: [
{
send: 'Hello, WebSocket!',
expect: 'Hello, Client!'
}
]
});
runner.run().then(results => {
console.log('Test Results:', results);
}).catch(err => {
console.error('Test Failed:', err);
});Configuration
You can customize the test runner using a configuration file:
{
"servers": [
"ws://localhost:8080",
"ws://localhost:9090"
],
"clients": 100,
"testCases": [
{
"send": "ping",
"expect": "pong"
}
]
}CLI Usage
Run tests directly from the CLI:
dws-test-runner --config test-config.jsonnpm run test
Executes the test cases and returns the results.
Contributing
Feel free to submit issues and pull requests! Contributions are always welcome.
License
This project is licensed under the MIT License.
