Category : testing

I’m trying to test my Angular application with jasmine, where a component has a click-and-copy functionallity. it(‘Should copy value to cilpboard’, () => { … spyOn(document, ‘execCommand’).and.callThrough(); // element.querySelector(‘#copy’).click(); // expect(document.execCommand).toHaveBeenCalledWith(‘copy’); }); But every time I ran my test I get the following error: spyOn : execCommand() method does not exist I didn’t declare "document" ..

Read more

I am writing tests for my angular web application that contains a page with a firebase UI element. There are two tests, one that ensures the page loads and one that ensures the firebaseUI component loads correctly: authentication.component.spec.ts /*eslint-env jasmine*/ import { ComponentFixture, TestBed } from ‘@angular/core/testing’; import { NO_ERRORS_SCHEMA } from ‘@angular/core’; import { ..

Read more

Estaba desarrollando una App en Angular 8, y al intentar testear uno de los componentes de la App, me he encontrado con el siguiente error: ERROR in ./src/lib/components/escaparate-banner/escaparate-banner.component.spec.ts Module not found: Error: Can’t resolve ‘@orange/redux/lib/services/actionsBack.service’ in ‘C:UsersmlucassaANGULAR_PROYECTSdetalle-terminal-library-typescript (3)srclibcomponentsescaparate-banner’ @ ./src/lib/components/escaparate-banner/escaparate-banner.component.spec.ts 8:28-85 @ ./src .spec.ts$ @ ./src/test.ts El tema esq todos lo modulos de los servicios ..

Read more

How do we mock the content which is consumed by the subscribe method..I am able to initialize the testService but struggling to mock the content of subscribe export class AppComponent { constructor(){} CheckTestLink(link: any) { this.testService.init().subscribe( configUsers => { const conf: [] = configUsers[‘entries’].filter( entry => (this.userName === entry.content.properties.user_name ); if (conf.length > 0) { ..

Read more

I am looking for a way to test if a child component has a specific class in a tested component. It’s probably best to show it by example. The parent component is a keyboard component with an HTML excerpt as shown below, it’s named EnglishKeyboardComponent with the corresponding english-keyboard.component.html (it contains keys for the English ..

Read more

@Component({ selector: ‘app-entity-details’, templateUrl: ‘./entity-details.component.html’, styleUrls: [‘./entity-details.component.scss’], viewProviders: [{ provide: ControlContainer, useFactory: (container: ControlContainer) => container, deps: [[new SkipSelf(), ControlContainer]], }] }) export class EntityDetailsComponent{ I have found the above setup using viewProviders on my Component as a way to use nested Formgroups within nestes Components without manually handling those as Input and/or output. Now ..

Read more