lensesio / cypress-websocket-testing

Test WebSocket connections with Cypress
Apache License 2.0
83 stars 12 forks source link

In javascript example where i should put channel name at ? cy.stream! command #7

Closed nehalbadelhafez closed 4 years ago

nehalbadelhafez commented 4 years ago

what I need to do is to subscribe on the channel and wait until special message come, I have tried cy.stream with subscribe but I can't find where I should but channel name to get a confirmation message on subscription

dsebastian commented 4 years ago

Hi @nehalbadelhafez , what do you mean by "channel name"?

nehalbadelhafez commented 4 years ago

var payload = { command: "subscribe", identifier: '{"channel":"LogsChannel"}' }; like this, as I have number of channel and I need to subscribe to specific one

dsebastian commented 4 years ago

You can use the startUpMessage property of the cy.streamRequest, as in the docs. That payload will be sent once the connection has been made, and you should set takeWhileFn to check for the confirmation message for your subscription.

nehalbadelhafez commented 4 years ago

could you please show me an example, also the docs where ? as the docs contains typescript I need javascript example

dsebastian commented 4 years ago

See this example: https://github.com/lensesio/cypress-websocket-testing/blob/master/examples/cypress/integration/examples/streamRequest.spec.ts#L60

It's the same in Javascript, just remove the types.

nehalbadelhafez commented 4 years ago

ok I will try it thank you so much

dsebastian commented 4 years ago

Closing issue then.