akveo / akveo/nebular

AuthModule inheritance and component test

Open
#1,318 3 comments 0 reactions 0 assignees View on GitHub
needs info
Dominant language
TypeScript
Stars
8.1k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

Hi,

### Issue type

**I'm submitting a ...**

* [X] bug report
* [ ] feature request

### Issue description

I started to customize the auth components. For example, I'm extending the NbLoginComponent like that :

```typescript
export class LoginComponent extends NbLoginComponent {

}
```

The fact is I'm trying to test my newly created component and the test fails. I started to add dependencies like those one :

```typescript
TestBed.configureTestingModule({
imports: [ AuthModule ], // My module containing all extended components
providers: [
NbAuthService,
NbTokenService,
NbAuthTokenParceler,
{ provide: NbTokenStorage, useClass: NbTokenLocalStorage }
]
})
```

At this point, I'm encountering this error :

```
Error: StaticInjectorError(DynamicTestModule)[NbAuthTokenParceler -> InjectionToken Nebular Auth Options]:
StaticInjectorError(Platform: core)[NbAuthTokenParceler -> InjectionToken Nebular Auth Options]:
NullInjectorError: No provider for InjectionToken Nebular Auth Options!
```

This error is generated by this default test :

```typescript
it('should create', () => {
expect(component).toBeTruthy();
});
```

I searched through issues and repositories but I didn't find any component test. Is there a way to correctly test a component extending as Nebular component ?

Thank you !

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.