Aller au contenu principal

BaseTools

Every test beds tools extends these tools.

injector

Test bed injector to get instances.

Example :

it('should ', tb(({ injector }) => {
const service = injector.get(AppService);
// ... expectations
}));

injected

Get instances injected with tb.inject(..) by autocompletion.

Example :

describe('AppComponent', () => {
const tb = componentTestBed(AppComponent)
.inject('auth', AuthService);

it('should ', tb(({ injected: { auth } }) => {
// ... expectations
}));
});

rx

RxBox to auto unsubscribe Subscription and auto complete Subject when the test ends.

Uses the remind setter to add subscription or subject into local array.

Example :

it('should ', tb(({ rx }) => {
// Auto unsubscribe after the test end
rx.remind = myObservable.subscrible();

// Auto complete after the test end
const subject = new Subject();
rx.remind = subject;

// ... expectations
}));