Welcome to my blog !

How to write unit testing static methods in a class of Angular and typescript

February 21, 2023 ·  2 min read

In this tutorial, You learned how to do unit test static methods of typescript classes. It includes an example of how to test a component using the static method in Angular. Let’s declare an ES6 class in typescript with static methods. export class StaticClass { static getMessage(name: string): String { return 'Hi' + name + 'Welcome to my blog'; } } Here is a Unit test class for the ES6 class with a static method...

How to write unit testing for private and static in Angular and typescript

February 21, 2023 ·  2 min read

This tutorial covers how to write unit testing for private methods in Angular applications. Private methods are private to the same class. It does not allow access outside in public methods of a typescript class. Writing Angular unit testing for private methods Let’s declare a class. export class Employee{ private calculateSalary(){ console.log("Private method to calculate salary") } public getTotalSalary(){ console.log("Return total salary of an employee") } } calculateSalary() is a private method that is accessible in public method getTotalSalary()....

How to write unit testing for Angular Service classes and httpclient dependencies Angular

February 21, 2023 ·  5 min read

In this tutorial, you learn how to unit test angular services with example test cases. It also includes the following things How to set up a unit test Angular service. Unit test service functions Mock dependencies with jasmine library Assert expected and actual with karma library Unit testing is testing a piece of code with runs as expected. In my previous post, We discuss complete tutorials on Angular service with examples....

how to fix 404 errors for webserver during karma unit testing Angular

February 21, 2023 ·  2 min read

Learn to fix webserver 404 not found errors in testing angular components or directives. This post includes a solution for 404 errors for loading assets files like json and images during running karma runner. 2021 01:06:33.123:WARN [web-server]: 404: /assets/arrow.png 2021 01:06:33.123:WARN [web-server]: 404: /assets/down.png Suppose you have a component that uses png or any image files, You will get an error while unit testing a component. Generally, When the ng test command is issued, It runs a web server and executes unit testing running ng serve and ng test are different environments....

How to change Remote URL git remote repository

February 21, 2023 ·  2 min read

This tutorial explains how to change the remote repository for an existing local repository This will be used once you migrated the repository from different repositories such as GitHub, GitLab, and bitbucket. How do I change the URI (URL) for a remote Git repository? Following are the steps required to change the GitHub remote repository. One way using the command line Git View the existing remote repository First, run the git remote -v command on an existing repository...

You'll get a notification every time a post gets published here.