Questions tagged [angular-unit-test]

Questions about Angular unit testing. Use this tag for Angular unit testing questions which are not specific to an individual version. Do not use this tag for the older AngularJS (1.x) web framework uni testing questions.

Angular unit testing is based on two systems. Jasmine (The testing framework) and Karma (The test runner).

The Angular CLI takes care of Jasmine and karma configuration for you.

You can fine-tune many options by editing the karma.conf.js and the test.ts files in the src/ folder.

The projects that you create with the CLI are immediately ready to test. Just run ng test CLI command to run the tests.

Useful Links

256 questions
0
votes
0 answers

Test jasmin angular @ViewChild

I have the following component Delete Confirmation Do you want to delete all the data related to shipping, distribution and storage?
0
votes
1 answer

How to write a test case for multiple if else statement in angular 9

I am trying to write test case for below method but i don't know how to write the test case to cover the code: getSectionName(sectionId: string) { if (sectionId === sectionIds.Homepage) { return Section.Homepage; } else Iif (sectionId…
Angular js
  • 51
  • 9
0
votes
0 answers

Jasmine test involving Observables

I'm pretty new to jasmine testing, and have no idea how to work with observables and stuff like '.subscribe' etc. Need some help with workaround for a snippet like: getOrder(partId: number, projectId: number) { if (projectId != null || undefined) { …
0
votes
2 answers

Angular: TestCase For Custom Pipe

I am new in Unit testing and i need help in writing TestCase for Sort Pipe in karma. My Custom Sorting Pipe is calling Methods Based on DirectionValue,In which the logic for sorting are. @Pipe({ name: 'sortBy' }) export class SortByPipe implements…
tiana
  • 374
  • 1
  • 8
  • 23
0
votes
1 answer

How to generate unit test case code coverage report in .pdf for all components using angular9 and Jasmine

Angular support code coverage report in .html format(Index.html). The same code coverage report can it be possible to get in .pdf version using angular 9/Jasmine? I had tried to modified some settings in Karma.config.js file but no luck. Is any…
0
votes
1 answer

Angular jest, test if inside observable

Function to be tested changeIva(idTax: number, index: number): void { this.documentService.getTaxById(idTax).subscribe(tax => { if (tax.codigo === 'ISE') this.openModal(index); }); } How far I've come it('should test whether the…
0
votes
0 answers

Angular Unit Testing facing problem in initialization form and subscribing value changes of form

i'm new in unit testing in angular actually i facing a issue while initialization of form group it('should be able to init forms', () => { service.organizationForm = formBuilder.group({}) service.initOrganizationForm() }) while…
0
votes
1 answer

Jest unit test "Cannot find control with unspecified name attribute"

I'm doing some simple components for my "dynamic-ish" automated form creator and I've just made a component for dropdown: