A new library for logging and testing RxJS observables #6007
ivan7237d
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wanted to share a library 1log that I've built for logging observables. Here is a screenshot:
Observables and subscriptions are assigned numbers, and these numbers let you tell which subscription a specific next/error/completion/unsub applies to. Log messages also use indentation to show synchronous stack level, and this helps in situations like reentrancy-related bugs.
The library started as a logging utility specifically for observables, but now RxJS-specific logic is in a plugin (there are also plugins for logging functions, promises, and iterables), while the core of the library takes care of such things as severity levels and badges.
Although this wasn't the initial plan, it turned out that logging in combination with Jest snapshots can be a good way to test observables (since v6.2.1, RxJS works well with Jest's fake timers). Here's a small sample Jest test:
You can find more details in an article I've posted on dev.to, and let me know what you think.
Beta Was this translation helpful? Give feedback.
All reactions