How to use the mock-socket/src/event-factory.createMessageEvent function in mock-socket

To help you get started, we’ve selected a few mock-socket examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github t2t2 / vue-syncers-feathers / test / helpers / mock-socket.js View on Github external
emit(event, ...data) {
		if (this.readyState !== BaseSocketIO.OPEN) {
			throw new Error('SocketIO is already in CLOSING or CLOSED state')
		}

		// Emulate connection by re-creating all objects
		data = cloneDeepWith(data, cloneCustomiser)

		const messageEvent = createMessageEvent({
			type: event,
			origin: this.url,
			data
		})

		// Dispatch on self since the event listeners are added to per connection
		this.dispatchEvent(messageEvent, ...data)
	}

mock-socket

Javascript mocking library for websockets and socket.io

MIT
Latest version published 1 year ago

Package Health Score

63 / 100
Full package analysis