Skip to content
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

Support Time progression syntax #117

Open
prumand opened this issue Jul 11, 2019 · 8 comments
Open

Support Time progression syntax #117

prumand opened this issue Jul 11, 2019 · 8 comments
Labels
enhancement New feature or request

Comments

@prumand
Copy link

prumand commented Jul 11, 2019

I couldn't get the following marble to run with jest-marbles, but it worked fine with the normal testScheduler setup. Cold and hot just give me frames for every letter/digit.

// standard rxjs setup
expectObservable(obs).toBe(' 5000ms b')

// jest-marbles
cold(' 5000ms b')
hot(' 5000ms b')

I hope that's enough info to reproduce.

npm info = [email protected]

@just-jeb
Copy link
Owner

I'll look into this.

@just-jeb
Copy link
Owner

just-jeb commented Jul 18, 2019

Ok, the issue is identified. jest-marbles use TestScheduler in the old way (outside of run method). Time progression syntax is not supported in this way.
I'll issue a new major version that uses run method but most likely it will take some time because the documentation has to be aligned and there are syntax differences between the two ways.
How urgent is this for you?

@just-jeb just-jeb added the enhancement New feature or request label Jul 27, 2019
@just-jeb just-jeb changed the title Cannot use Time progression syntax Support Time progression syntax Jul 27, 2019
@prumand
Copy link
Author

prumand commented Jul 30, 2019

Thank you very much.

As you see, not urgent at all (vacation-time 🌴). I just used the rxjs TestScheduler.

@HanDDol
Copy link

HanDDol commented Apr 2, 2020

Is it not implemented yet?

@just-jeb
Copy link
Owner

just-jeb commented Apr 2, 2020

Unfortunately not yet. But any contribution is welcome.

@leonard84
Copy link

leonard84 commented Jun 8, 2020

This explains, why I couldn't get my tests working. Any timeline on this change?

Is this also the reason why debounceTime doesn't seem to work. It only emits when the stream completes instead of after 250ms no matter how many frames - I use.

    it('debounce', () => {
      const input = cold('a--------------------------b-------------------------|', {a: 'demo', b: 'demo.w'})
      const expected = cold('--------------------------a--------------------------(b|)',
        {a: 'demo', b: 'demo.w'})

      expect(input.pipe(debounceTime(250))).toBeObservable(expected)
    });

Expected notifications to be:
  [{"frame": 260, "notification": {"error": undefined, "hasValue": true, "kind": "N", "value": ["com.demo.backend", "com.demo.webapp"]}}, {"frame": 530, "notification": {"error": undefined, "hasValue": true, "kind": "N", "value": ["com.demo.webapp"]}}, {"frame": 530, "notification": {"error": undefined, "hasValue": false, "kind": "C", "value": undefined}}]
But got:
  [{"frame": 530, "notification": {"error": undefined, "hasValue": true, "kind": "N", "value": ["com.demo.webapp"]}}, {"frame": 530, "notification": {"error": undefined, "hasValue": false, "kind": "C", "value": undefined}}]

@just-jeb
Copy link
Owner

Hey @leonard84, unfortunately time progression is still not supported and I'm struggling to see when I'll be free to do this. Contributions are welcome.
That being said I don't think your issue is related to this. Does it work if you use RxJs TestScheduler?
They did mention that the default time frame could change to 1 per - instead of 10 per - in future versions. What version you're using?

@sonic1981
Copy link

If your using TestScheduler you can achieve this using the inbuilt hot and cold methods without using jest-marbles at all, simply:

testScheduler.run(helpers  => {

      const { cold, expectObservable } = helpers;

};

cold has a slightly different syntax but at least it all supports proper timeframes. Not really sure what the point of a marble diagram library that doesn't support time is...seems a bit pointless given that you can achieve the same thing using existing libraries that work fine inside of jest 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants