🌐
Angular
angular.dev › guide › testing › components-basics
Basics of testing components • Angular
A component, unlike all other parts ... the class working together. To adequately test a component, you should test that they work together as intended....
🌐
Angular
angular.dev › guide › testing
Testing • Overview • Angular
Creating harnesses for your components · Adding harness support for additional testing environments · Migrating from Karma to Vitest · Testing with Karma and Jasmine · Zone.js Testing Utilities · In-depth Guides · Testing · Testing your Angular application helps you check that it is working as you expect.
Discussions

What makes a good Angular component test?

User Experience (navigating to another page) should be done with end-to-end like Cypress.

If you have a button with a link that has a dynamic url that has some logic you need to test that logic/url in your unit test. But not the behavior.

I would validate a form, not a field. If your test is to big it's probably because your form is to big.

More on reddit.com
🌐 r/Angular2
6
9
February 27, 2024
How do you test your Angular app
Playwright https://playwright.dev/ More on reddit.com
🌐 r/Angular2
20
23
August 9, 2024
Are component tests worth it?

e2e tests are easier to write and find more bugs. You should start with those first. Those are more difficult to get started with if your app requires user authentication. But once you solve that problem with your tests, e2e is a better pay-off

Once you've got e2e tests that hit at least every page on your site, and every http call that it makes, component tests now fill in the gaps for your testing. They're more difficult to write, but not by a lot. They don't catch as many bugs, since e2e tests will catch not only frontend bugs, but backend bugs (if a data model changed on the backend, or it's suddenly throwing a 500, for example). But, they allow you to your components a little more carefully. They also run a lot faster than e2e tests. I use to have over 10 boxes running in parallel on GitHub actions for a few hundred e2e tests. You really don't need to bother with parallel boxes for component testing.

More on reddit.com
🌐 r/angular
10
16
June 21, 2022
Which part of my Angular2 app are worth unit testing

Stubs/Mock everywhere is a terrible idea, it makes you produce thousand of lines of code that will test itself instead of testing your application in real condition.

Why is it a terrible idea to stub everywhere? Normally if you use a proper stubbing framework, that shouldn't take thousands of line of code. There are certainly cases where mocking isn't the right approach, but most of the time it's OK in my opinion.

The goal of unit testing is not to deal with "real" cases, that's what E2E and integration testing is for. With unit testing you try to test a specific piece of API, and to do that, you often try to abstract all its dependencies by stubbing them.

The "just say no more to E2E tests" mentions a 70/20/10 rule. The reasoning behind this is that writing E2E tests is time consuming. If you would E2E test everything, developing might take 2 times longer than it would without. But as usual, it's about finding the right strategy. Not writing E2E tests has its implications as well.

About the RxJS code, since you're talking bout a HTTP call and transforming the data, I would stub Http and write 2 unit tests:

  • One that makes sure that the call to Http is made correctly. So in your case you would be sending your JWT token with it?

  • One that retrieves the result. You can subscribe to your observable in your test and test the response that comes from it.

You may want to verify how to properly write tests with asynchronous code though. You don't want your test to end before you actually receive a value from your observable.

More on reddit.com
🌐 r/Angular2
7
16
October 24, 2016
🌐
Angular
angular.dev › guide › testing › components-scenarios
Component testing scenarios • Angular
This guide explores common component testing use cases. ... In the example application, the Banner component presents static title text in the HTML template. After a few changes, the Banner component presents a dynamic title by binding to the component's title property like this. import {Component, signal} from '@angular/core'; @Component({ selector: 'app-banner', template: '<h1>{{ title() }}</h1>', styles: ['h1 { color: green; font-size: 350%}'], }) export class Banner { title = signal('Test Tour of Heroes'); }
🌐
Testim
testim.io › blog › angular-component-testing-detailed-guide
Angular Component Testing: A Detailed How-To With Examples
June 18, 2025 - Angular component testing means to check the quality and performance of your components. Angular component testing can be done manually by running the application yourself and checking to see if a component’s behavior is working as expected.
🌐
Medium
medium.com › ngconf › angular-testing-component-testing-8a26609ecc22
Angular Testing: Component Testing | by Quantarius Ray | ngconf | Medium
December 5, 2022 - Part 2 of my Angular Testing taking an in-depth look at Component Testing with Cypress. TDD and create smaller, atomic components!
🌐
Angular
v17.angular.io › guide › testing-components-basics
Basics of testing components
Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular.
🌐
Testing-angular
testing-angular.com › testing-components
Testing Components – Testing Angular
Introduction to testing Angular Components with Angular’s TestBed
🌐
Cypress
docs.cypress.io › app › component-testing › angular › overview
Angular Component Testing | Cypress Documentation
Learn how to set up component tests in Angular and configure Cypress for Angular projects.
Find elsewhere
🌐
Angular
v17.angular.io › guide › testing-components-scenarios
Component testing scenarios
Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular.
🌐
ANGULARarchitects
angulararchitects.io › home › blog › testing angular standalone components
Testing Angular Standalone Components - ANGULARarchitects
September 4, 2023 - New Standalone APIs provide mocks for test automation. ... With Standalone Components, Angular becomes a lot more lightweight: NgModules are optional and hence we can work with lesser indirections. To make this possible, components now refer directly to their dependencies: other components, but also directives and pipes.
🌐
Testomat
testomat.io › home › jest angular: how to test angular components and use mocks
Jest Angular Component Testing: Guide & Mock Examples
March 21, 2025 - This Angular Component Testing with Jest tutorial provides a step-by-step guide on setting up Jest for testing Angular components. It explains how to configure Jest as a replacement for Playwright Angular component testing or Cypress alternatives and how to handle common challenges with complicated dependencies in the framework.
Address   Ul. Koszykarska 27b-26, Kraków
🌐
Angular
v17.angular.io › guide › testing
Testing Guide
Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular.
🌐
CodeCraft
codecraft.tv › courses › angular › unit-testing › components
Testing Components • Angular - CodeCraft
We can test inputs by just setting values on a component’s input properties. We can test outputs by subscribing to an EventEmitters observable and storing the emitted values on local variables. In combination with the previous lectures and the ability to test inputs and outputs we should ...
🌐
Testing Library
testing-library.com › introduction
Angular Testing Library | Testing Library
July 2, 2024 - As part of this, you want your ... your tests and slow you and your team down. The Angular Testing Library is a very lightweight solution for testing Angular components....
🌐
DEV Community
dev.to › coly010 › unit-testing-angular-component-testing-2g47
Unit Testing Angular - Component Testing - DEV Community
February 15, 2020 - If we run ng test from the command line, we will see that the tests pass correctly. Wonderful. Hold up! Having two methods that essentially do the same thing is duplicating a lot of code. Let's refactor our code to make it a bit more DRY: import { Component, Input, Output, EventEmitter } from '@angular/core'; @Component({ selector: 'app-user-speak', template: ` <div>Hello {{ name }}</div> <div> <button (click)="saySomething('Hello')">Say Hello</button> <button (click)="saySomething('Goodbye')">Say Goodbye</button> </div> ` }) export class UserSpeakComponent { @Input() name: string; @Output() readonly speak = new EventEmitter<string>(); constructor() {} saySomething(words: string) { this.speak.emit(words); } }
🌐
Angular Minds
angularminds.com › blog › mastering-angular-component-testing-a-step-by-step-guide
Mastering Angular Component Testing: A Step-by-Step Guide
June 20, 2024 - This guide provides a step-by-step approach, taking you from the basics to testing inputs, outputs, and routing. Learn valuable techniques to ensure the quality and reliability of your Angular applications.
🌐
Angular
angular.dev › guide › testing › using-component-harnesses
Using component harnesses in tests • Angular
The Component Dev Kit (CDK) is a set of behavior primitives for building components. To use the component harnesses, first install @angular/cdk from npm. You can do this from your terminal using the Angular CLI: ... You can use component test harnesses in different test environments.
🌐
Halodoc Blog
blogs.halodoc.io › angular-component-dom-testing
Deep dive into Angular component DOM testing - Halodoc Blog
June 22, 2023 - In this blog, we will dive deep into component testing and talk about DOM testing and we will also go through some of the important aspects of unit tests that we should be knowing for creating TestBed. We will also cover writing some performant UTs. ... As Angular rightly defines, the component is more than just class itself.
🌐
LogRocket
blog.logrocket.com › home › angular unit testing tutorial with examples
Angular unit testing tutorial with examples - LogRocket Blog
November 19, 2024 - By writing a unit test for your blocks (components, services, etc.), you can easily detect when there is a break. Our example Angular app has a service, a component, and an async task to simulate data being fetched from the server:
🌐
Angular Experts
angularexperts.io › blog › material-component-testing
Angular Material components testing - Angular Experts
Classic component test and harness ... test which test the GOT search field filter · Harness testing in Angular allows for easier, more readable and efficient component testing....