Ask Your Question
1

What is the process for testing an infinite stream using Jasmine Marbles?

asked 2023-06-13 01:25:04 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-06-13 01:32:01 +0000

huitzilopochtli gravatar image

The process for testing an infinite stream using Jasmine Marbles has several steps:

  1. First, import the necessary modules into your test file:
import { TestScheduler } from 'rxjs/testing';
import { cold } from 'jasmine-marbles';
  1. Create a new instance of the TestScheduler class:
const scheduler = new TestScheduler((actual, expected) => {
  expect(actual).toEqual(expected);
});
  1. Define your input stream using the cold function from jasmine-marbles. This function takes a string as its argument, representing the values emitted by the stream over time. For example:
const input = cold('a-b-c-d-|');
  1. Define your expected output stream using a similar cold function:
const expectedOutput = cold('a-b-c-d-|');
  1. Subscribe to your input stream and expect it to equal your expected output using the expectObservable function:
scheduler.expectObservable(input).toBe(expectedOutput);
  1. Finally, flush the test scheduler to execute the test:
scheduler.flush();

This will test whether the input stream emits the expected values at the expected times.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-13 01:25:04 +0000

Seen: 21 times

Last updated: Jun 13 '23