-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Marble Testing #461
Comments
https://github.com/ReactiveX/rxjs/blob/5a2266af8770463156a67527ee3aca990cfd0365/spec/helpers/tests2png/painter.js Seems to be the file handling the painting of the graph |
Hi @thomas-jeepe, it's awesome that you put together a POC for this. Thanks! I haven't had time to look at it thoroughly yet, but I'll try to do that soon. In the meantime, have a look at It isn't specifically tailored for testing--for example, it doesn't have something like your I wonder if we could find a way to align that and your work on most-marble. I'd love to hear any thoughts you have. |
Ok, so I looked through your POC. I'll outline the differences. First, my package isn't too much different under the hood. The marble diagram is simply a way to convert data into an array of events, which is a similar implementation to yours. const events = parseMarbles('123|', undefined, 10)
expect(events).toEqual([
new Next(1, 0),
new Next(2, 10),
new Next(3, 20),
new End(30)
])
I don't currently have a class such as For Creating a stream from the events is very similar between both implementations. Mine is rather simplistic and simply schedules delays then runs the events. It seems to generate valid enough streams. The next part is getting events from a stream, I use a However, in order to bypass the timing, I used a The rest of my api is simply wrappers around
stream = (marbles: string, values?: { [name: string]: any }) => {
const events = parseMarbles(marbles, values, this.timeFactor)
return new MarbleStream(events)
} For running tests, I use a flushing approach similar to RxJs. When you
So, I ended up reimplementing many sections of your If |
Thanks for all the detail @thomas-jeepe. It does seem like the two approaches have a lot in common! I'm planning to respond in more detail in the next day or so ... hoping we can keep moving this forward. |
Marble testing for me is one of the large advantages of rxjs, it is very clear and easy to use and describes the code well. The current solution is using a virtual timer and ticking forward x milliseconds, which works fine, but I don't find it as declarative.
I decided to make a most-marble do see if I could get it to work, and I got it working pretty well.
Here is an example:
When compared to a similar stream tested with only the virtual timer, it looks far more declarative:
The repo for most-marble is here. As a quick note, I am pretty unfamiliar with most's internals, so I probably implemented the Scheduler and MarbleSource incorrectly, although it works.
So, there are current limitations on my marble testing as specified at the end of the README, however, I wanted to get the mostjs contributors' opinions on what I am doing and to put something out there.
Also, Rxjs 5 generates very nice picture graphs from marble tests that are used as documentation. I was thinking that if most had something similar, it could make some of the documentation nicer and friendlier to newcomers.
Summary
Marble testing is awesome, I implemented a subset of marble testing with most and it is really nice. I would like to work with mostjs contributors to make it full and make it more official and I would also like to see if generating diagrams from marble tests for operator documentation would be possible and wanted.
I also will begin to use this on my own project which I built it for, meaning the repo might change over time.
The text was updated successfully, but these errors were encountered: