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

toBeObservable does not work with with Ngrx mockStore.overrideSelector #396

Open
Itrulia opened this issue Nov 16, 2021 · 3 comments
Open

Comments

@Itrulia
Copy link

Itrulia commented Nov 16, 2021

While upgrading our repository from Nx 11.x & Angular 11.x to Nx 13.1.4 and Angular to v12.x we noticed all of our expect(result).toBeObservable(expected) that used store.overrideSelector started to fail. We narrowed it down to jest-marbles not properly working anymore.

Reproduction and more information can be found in this repository: https://github.com/Itrulia/jest-marbles-ngrx-bug

@Itrulia Itrulia changed the title toBeObservable does not work with with Ngrx mockStore.overrideSelector toBeObservable does not work with with Ngrx mockStore.overrideSelector Nov 16, 2021
@schmkr
Copy link

schmkr commented Nov 19, 2021

I think we ran into the same bug. What I had drilled this down to, was the jest runner being used. At some point, that switched from jest-jasmine2 to jest-circus.

If you set testRunner: 'jest-jasmine2' in jest.preset.js, your tests should succeed again.

But your details here, might help solve the underlying issue.

@Idicious
Copy link

Idicious commented Jan 17, 2022

If you set testRunner: 'jest-jasmine2' in jest.preset.js, your tests should succeed again.

We already have this in our jest.preset.js and are experiencing this issue.

To add to this, the import order in the test file is significant. This only seems to happen when the jest-marbles import (or the import of another module which imports jest-marbles), is above the import from @ngrx/store/testing.

Works

import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { cold, hot } from 'jest-marbles';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { foo } from 'module-importing-jest-marbles';

Fails

import { cold, hot } from 'jest-marbles';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { foo } from 'module-importing-jest-marbles';
import { MockStore, provideMockStore } from '@ngrx/store/testing';

@pavelrazuvalau
Copy link

pavelrazuvalau commented Dec 22, 2022

I think we ran into the same bug. What I had drilled this down to, was the jest runner being used. At some point, that switched from jest-jasmine2 to jest-circus.

If you set testRunner: 'jest-jasmine2' in jest.preset.js, your tests should succeed again.

But your details here, might help solve the underlying issue.

Thank you so much. I was struggling with it for many days during dependencies upgrade. I also tried to use jasmine-marbles since it supports jest-circus, however, some of my tests were still failing, so enforcing using the jest-jasmine2 test runner solved the issue with failing marble tests.

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

No branches or pull requests

4 participants