RxJS first() for Observable.of() - no elements in sequence

.first() will emit exactly one item or throw an error (if no defaultValue parameter was provided), so calling it on an empty observable will cause an error. This is the expected behavior based on the documentation.

If you would like to get at most one item from the observable, use .take(1).


The documentation for first() says:

Delivers an EmptyError to the Observer's error callback if the Observable completes before any next notification was sent.

So the error happens because your test data don't pass the filter() operator and emit complete immediately.