ngxs-examples icon indicating copy to clipboard operation
ngxs-examples copied to clipboard

unit tests

Open gforceg opened this issue 5 years ago • 3 comments

This lib is really great, but I'm trying to make an effort to unit test all of my code and I was hoping to find examples of unit tests. Specifically the DI piece and mocking the NGXS pieces.

When my component constructor takes in the store as a constructor and I import NgxsModule.forRoot([MyState]) in the TestBed my tests still fail w/ "Can't resolve all parameters for <COMPONENT>".

This would be a great repo to show how to unit test an app that uses NGXS including mocking.

gforceg avatar Dec 27 '19 13:12 gforceg

@markwhitfeld @arturovt

splincode avatar Dec 27 '19 15:12 splincode

I was complicating things by using jest w/ the jest-presets-angular package and experimental decorators were turned off which screwed up the DI in my testbed. I feel a lot more sane now that the DI is working and I can mock Store.

Still, I think adding unit tests to the examples is a good idea and I'm willing to contribute to this repo personally.

gforceg avatar Dec 27 '19 15:12 gforceg

Thanks @gforceg, I welcome any contributions you would like to make to this.

markwhitfeld avatar Dec 27 '19 19:12 markwhitfeld