Category : karma-runner

It usually happens in Jenkins, and to me it seems that Karma is trying to launch testing while the generating bundle process is on its way to get completed, so I was wondering whether there is a way to make Karma to use an existing bundle, or generate a bundle first and then launch karma ..

Read more

Very similar to my last Karma upgrade issue in this post, I have all my unit test for a component failing after upgrading from v7 to v8. Once again due to a custom component from a shared library. So here I get the following.. NullInjectorError: StaticInjectorError(DynamicTestModule)[ProgressIndicatorComponent -> ElementRef]: StaticInjectorError(Platform: core)[ProgressIndicatorComponent -> ElementRef]: NullInjectorError: No provider ..

Read more

I have such intercept method in my app with following code: intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { if (request.url.split(‘/’).includes(‘login’)) { return next.handle(request); } else { if (request.url.split(‘/’).includes(‘refresh’)) { return next.handle(request).pipe(catchError(error => { if (error instanceof HttpErrorResponse && error.status === 400) { this.dialogRef.closeAll(); this.router.navigate([‘/login’]); } else { return throwError(error); } })); } else { if (this.authService.getAccessToken()) ..

Read more

Continuing my journey of updating our Angular projects from 7 to 8 (first step on the way to 12), I continue to have most problems in the unit tests. This time I am getting… Error: No component factory found for CalendarHeaderComponent. Did you add it to @NgModule.entryComponents? at noComponentFactoryError (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm5/core.js:18161:1) at CodegenComponentFactoryResolver.push../node_modules/@angular/core/fesm5/core.js.CodegenComponentFactoryResolver.resolveComponentFactory (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm5/core.js:18208:1) at CdkPortalOutlet.push../node_modules/@angular/cdk/esm5/portal.es5.js.CdkPortalOutlet.attachComponentPortal ..

Read more

@Input() public openDrawer: BehaviorSubject<{ open: boolean; assetConditionDetails: AssetConditionIdDetails[]; selectedAssets: SelectedAssets[]; }>; public ngOnInit(): void { this.openDrawer.subscribe((result) => { if (result) { this.showLoader = result.open; this.isDrawerActive = result.open; this.selectedAssets = result.selectedAssets; this.assetConditionDetails = result.assetConditionDetails; } }); } can someone please tell me how to write a unit test case for this ..? this is what I ..

Read more

import { HttpClientModule } from ‘@angular/common/http’; import { CUSTOM_ELEMENTS_SCHEMA } from ‘@angular/core’; import { NO_ERRORS_SCHEMA } from ‘@angular/core’; import { async, ComponentFixture, TestBed } from ‘@angular/core/testing’; import { RouterModule, Routes } from ‘@angular/router’; import { DrawerService} from ‘../services/create-work-order-confirmation-drawer.service’; import { HttpClientTestingModule, HttpTestingController} from ‘@angular/common/http/testing’; import { ConfirmationDrawerComponent } from ‘./create-work-order-confirmation-drawer.component’; import { FormsModule } from ..

Read more

I am getting "Can’t bind to ‘formGroup’ since it isn’t a known property of ‘form’" error (it(‘should create’, () => {} ) test for every component using formGroup in my app. The app is working fine. I have imported FormsModule & ReactiveFormsModule in every module. <form [formGroup]="uploadDocumentFormGroup"> export class UploadFormComponent implements OnInit { public uploadDocumentFormGroup: ..

Read more