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

Unit Tests Breaking : Uncaught TypeError: Cannot read property 'entities' of undefined #1546

Closed
cport1 opened this issue Feb 8, 2019 · 11 comments

Comments

@cport1
Copy link

@cport1 cport1 commented Feb 8, 2019

I am getting this error randomly on different unit tests. It breaks on a different unit test each time tests are ran. However, sometimes all tests pass successfully.

Angular Version: 7.2.4
@ngrx Version: 7.0.0

@cport1 cport1 closed this as completed Feb 8, 2019
@cport1 cport1 reopened this Feb 8, 2019
@cport1
Copy link
Author

@cport1 cport1 commented Feb 8, 2019

I think what ultimately fixes the issue is destroying the feature after create component

  beforeEach(() => {
    fixture = TestBed.createComponent(ComponentNameComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });
  afterEach(() => {
    fixture.destroy();
  });

@cport1 cport1 closed this as completed Feb 8, 2019
@BBlackwo
Copy link
Contributor

@BBlackwo BBlackwo commented Aug 16, 2019

It's quite annoying to have to add the fixture.destroy() in each component I'm testing. I've never had to do this for anything else as a fresh instance is always created in each beforeEach. Why is this necessary when using provideMockStore()?

Can this issue please be re-opened @cport1.

@cport1 cport1 reopened this Aug 26, 2019
@cport1
Copy link
Author

@cport1 cport1 commented Aug 26, 2019

I reopened the issue.

@flaviuse
Copy link

@flaviuse flaviuse commented Aug 28, 2019

Really annoying it's breaking our verification system, even with fixture.destroy() it randomly fail. We have git pre hooks that run test on push ...

@cport1
Copy link
Author

@cport1 cport1 commented Aug 29, 2019

Really annoying it's breaking our verification system, even with fixture.destroy() it randomly fail. We have git pre hooks that run test on push ...

Does it fail on a different component each run?

@timdeschryver
Copy link
Member

@timdeschryver timdeschryver commented Aug 30, 2019

Does anyone have a small reproduction of this behavior?

@timdeschryver
Copy link
Member

@timdeschryver timdeschryver commented Sep 3, 2019

Closing this in favor of #2044, because I think it's a duplicate.
If it's not the case feel free to create a reproduction and create a new issue.

@noylev
Copy link

@noylev noylev commented Jan 30, 2020

happens for me as well, I tried to add afterEach(() => { fixture.destroy(); }); in one test and it helped for more tests to pass, but then another random test had failed...

@rameezcm
Copy link

@rameezcm rameezcm commented Jun 10, 2020

i got the same issue

@pras7430
Copy link

@pras7430 pras7430 commented Sep 9, 2020

facing the same issue,

An error was thrown in afterAll error properties: Object({ longStack: 'TypeError: Cannot convert undefined or null to object

@aidanxyz
Copy link

@aidanxyz aidanxyz commented Feb 26, 2021

I had a similar error:
An error was thrown in afterAll error properties: Object({ longStack: 'TypeError: Cannot ...
and it turned out I just forgot to mock one selector, and the value which it was supposed to emit wasn't being checked in the given component tests, therefore sometimes everything would pass and sometimes throw an error.

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

No branches or pull requests

8 participants