Closed rizkysyazuli closed 3 years ago
Hi @rizkysyazuli , when switching from TS to JS, the types disappear. So the options/config are plain objects that you just need to pass to the request: // see rxjs possible config values const config = { url: 'ws://localhost:8081', ...etc }; // see lib options const options = { streamTimeout:2000, takeWhileFn: (msg)=>!!msg }; cy.streamRequest(config, options).then(results => { expect(results).to.not.be.undefined; })
ah. i see @dsebastian but it's still not clear where i should put the request payload.
thx
If you just need to send a message(payload) on connection open, you have the startUpMessage property: https://github.com/lensesio/cypress-websocket-testing/blob/master/examples/cypress/integration/examples/streamRequest.spec.ts#L66
ah.. yes @dsebastian i mean message. sorry. i'm also new with websocket. but yeah. i see the data now. thx!
so in case anyone's stumbled upon the same problem. here's my somewhat working code.
const config = {
url: 'ws://localhost/ws'
};
const options = {
startUpMessage: {
data: { ... }
}
};
describe('Page', () => {
it('Can do stuff', () => {
cy.streamRequest(config, options).then(response => {
// do some checks
});
});
});
The JS example in the README is missing the
config
andoptions
. How do I translate these from TS to JS? Could use abit more details on this.Here's what i did. I don't think I'm doing it right though. Coz it gives me an error.
Here's the error from Cypress:
Or when i changed the import from
WebSocketSubjectConfig
towebSocket
as seen in the RxJS doc.