How to apply test scheduler to nested operators.
hally9k opened this issue · 4 comments
I am trying to write an example marble test with rx-sandbox and jest and failing.
See repro -> https://github.com/hally9k/rx-sandbox-jest-example
The observable under test doesn't emit any output. I think the problem is that the test scheduler isn't applied to the delay operator but I can't seem to find how to do that from the readme here. Does rx-sandbox not patch the test scheduler into the operators automagically?
Does rx-sandbox not patch the test scheduler into the operators automagically?
In short, answer is no. rx-sandbox only manages test-scheduler observable created by its own interfaces (hot
, cold
respectively). This is same behavior to underlying virtual scheduler / or testschedule in rxjs core - for observables created out of scope from testscheduler implementation, it doesn't aware of what scheduler running into and test fixture setup need to inject scheduler manually.
This is somewhat inconvenient indeed, and rxjs core team currently discussing behavior around those between couple of possible mechanisms. rx-sandbox doesn't implement any own custom behavior yet and trying to make core level decision first.
@kwonoj - Does rx-sandbox expose it's scheduler so I can mock the import and manually pass it into the operators?
@hally9k yes - https://github.com/kwonoj/rx-sandbox/blob/master/src/RxSandboxInstance.ts#L21 it's not documented but exposed via type definition.
Apologies, but I don't seem to be able to figure out any way to inject the test scheduler into the operator for my test. Have you achieved this? Are you able to give me a little guidance?