question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

9.6.1 breaks tests with ngrx

See original GitHub issue

We upgraded ng-mocks to 9.6.1 today and several (about 10 of ~700) tests break because of ngrx missing injection tokens:

NullInjectorError: R3InjectorError(DynamicTestModule)[StoreFeatureModule -> InjectionToken @ngrx/store Internal Store Features -> InjectionToken @ngrx/store Internal Store Features]:
          NullInjectorError: No provider for InjectionToken @ngrx/store Internal Store Features!
        error properties: Object({ originalStack: 'Error: NullInjectorError: No provider for InjectionToken @ngrx/store Internal Store Features!

These now failing tests work absolutely fine with 9.5.0, @ngrx/effects 9.2.0 and @ngrx/store 9.2.0. I see that the Module mock has been totally refactored and as far as I can tell it now seems to sometimes miss the given imports of StoreModule.forRoot(), StoreModule.forFeature(), EffectsModule.forRoot() and EffectsModule.forFeature().

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
vokeit-gschustercommented, Jun 18, 2020

Test for MyComponent (in MyModule) fails with mocked “MyOtherModule” that has ngrx integrated.

describe('MyComponent', () => {
  TestBed.configureTestingModule({
    imports: [
      MockModule(MyOtherModule),
      HttpClientTestingModule
    ],
    declarations: [
      MyComponent,
      MyOtherComponent
    ],
    providers: [
      provideMockStore<AppState>(getMockState())
    ]
  })
  .compileComponents();

  //...
});

@NgModule({
  imports: [
    CommonModule,
    StoreModule.forFeature('xyz', xyzReducer),
    EffectsModule.forFeature([XyzEffects])
  ],
  providers: [
    XyzService
  ],
  declarations: [
    XyzComponent
  ],
  exports: [
    XyzComponent
  ],
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class MyOtherModule { }
0reactions
satanTimecommented, Jun 21, 2020

Hi there, 9.6.2 has been released. Please let me know how it works for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

9.6.1 breaks tests with ngrx · Issue #142 - GitHub
We upgraded ng-mocks to 9.6.1 today and several (about 10 of ~700) tests break because of ngrx missing injection tokens: NullInjectorError: ...
Read more >
Unit Testing NgRx Effects. Without Marbles | by Josh Hicks
I want to know that it: works as expected; doesn't break anything else; breaks if I make changes that should break it. These...
Read more >
The Complete Guide to NgRx Testing (2020)
This post will show you how to test NgRx apps, what to test for and how to create the tests with ease. Testing...
Read more >
Testing Angular with Cypress and Docker | TestDriven.io
This post details how to add end-to-end tests to an Angular app with Cypress and Docker.
Read more >
angular/fire - npm
NgRx friendly API - Integrate with NgRx using AngularFire's action based APIs. Lazy-loading - AngularFire dynamically imports much of Firebase, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found