New Angular CLI projects use Vitest by default: run ng test to start. Existing Karma projects remain supported, but moving them to Vitest is documented as experimental. For most unit tests, Angular’s Node.js and DOM-emulation setup is the faster starting point; use browser mode when the behavior depends on a real browser. Angular’s testing overview explains the current options.
Run Angular tests with the default setup
The Angular CLI includes Vitest and jsdom for new CLI projects. Vitest runs in Node.js, while jsdom supplies a browser-like DOM without launching a browser. Angular also documents happy-dom as an alternative DOM emulator.
-
Open a terminal at the Angular workspace root, where
angular.jsonis located. -
Run
ng test. In interactive use, the test target watches files and reruns tests when they change.Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
-
Read the test results in the terminal. If you need to debug browser-dependent behavior, configure browser mode as described below.
The exact test builder and options depend on the project configuration. Angular’s CLI manages most Vitest setup; the test target in angular.json can configure include and exclude patterns, setup files, provider files, coverage, browser selection, and a custom runner configuration. Custom runner configuration is an advanced route: Angular does not support the contents of custom configuration files or third-party plugins.
Run tests in CI
When the environment sets CI=true, Angular switches to non-interactive, single-run behavior. If your CI system does not set that variable, use ng test --no-watch --no-progress to avoid watch mode and progress output.
Choose between DOM emulation and a real browser
DOM emulation is a good default when tests exercise application logic and ordinary component behavior. It avoids starting a browser, which Angular describes as faster for most unit tests. It may not reproduce every browser API or rendering detail, however.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitches| Approach | Useful when | Trade-off |
|---|---|---|
| Node.js with jsdom or happy-dom | Most unit tests and fast feedback are the priority. | Browser behavior is emulated, not supplied by a real browser. |
| Browser mode | Tests depend on browser-specific APIs or rendering, or you need to debug in a browser. | Requires installing and configuring a browser provider and browser; startup adds setup and execution work. |
Angular documents Playwright and WebdriverIO providers. Install the provider you choose and configure the test target’s browsers option. In CI, browser mode uses headless operation automatically when the CI environment variable is set; you can also select a browser name that explicitly chooses headless mode. Check the current provider documentation for supported browsers and setup details before relying on a particular browser or version.
Test services with TestBed
A service test can use TestBed to create an isolated Angular testing environment, configure dependency injection, and retrieve the service under test. Unless you override a dependency, the test uses the real dependency registered in the test configuration. That can be useful for checking the actual application code path, but replace dependencies when you need a focused unit test or want to avoid external effects.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
import { TestBed } from '@angular/core/testing';
import { MyService } from './my.service';
describe('MyService', () => {
let service: MyService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(MyService);
});
it('creates the service', () => {
expect(service).toBeTruthy();
});
});
Replace MyService with the service and imports in your project. Add providers or test doubles to configureTestingModule when the service needs dependencies that you want to control.
Test components through their rendered behavior
A component combines a TypeScript class and an HTML template. Configure the component in TestBed, create a fixture, trigger change detection, and inspect the rendered result. A fixture gives access to the component instance and its rendered view; Angular’s DebugElement provides a platform-aware way to query and interact with that view.
import { TestBed } from '@angular/core/testing';
import { MyComponent } from './my.component';
describe('MyComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MyComponent],
}).compileComponents();
});
it('renders the component', () => {
const fixture = TestBed.createComponent(MyComponent);
fixture.detectChanges();
expect(fixture.componentInstance).toBeTruthy();
expect(fixture.debugElement).toBeTruthy();
});
});
This is a starting pattern, not a complete assertion for every component. Add expectations for the user-visible behavior the test is intended to protect, such as text, state changes, or event handling. Accessing nativeElement assumes the active DOM implementation exposes the APIs your test uses. Prefer Angular’s abstractions where they provide the behavior you need, especially if tests should work across environments.
Test HTTP requests without calling the backend
Angular’s @angular/common/http/testing package lets tests capture outgoing requests, assert their properties, and flush controlled responses. The test backend replaces real network access; tests must flush expected requests and verify that no unexpected requests remain.
import { provideHttpClient } from '@angular/common/http';
import {
HttpTestingController,
provideHttpClientTesting,
} from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { MyService } from './my.service';
describe('MyService HTTP behavior', () => {
let service: MyService;
let httpTesting: HttpTestingController;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
provideHttpClient(),
provideHttpClientTesting(),
MyService,
],
});
service = TestBed.inject(MyService);
httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
httpTesting.verify();
});
it('requests data and handles the response', () => {
service.getData().subscribe((data) => {
expect(data).toEqual({ value: 'example' });
});
const request = httpTesting.expectOne('/api/data');
expect(request.request.method).toBe('GET');
request.flush({ value: 'example' });
});
});
Adapt the service method, expected URL, and response shape to your application. If a test does not make the request it expects, it cannot flush that request; if it makes an unanticipated request, the verification step helps expose it.
Measure coverage without mistaking it for quality
For Vitest coverage, install @vitest/coverage-v8 using the package manager used by your project, then run ng test --coverage. Angular documents the resulting report in the coverage/ directory. You can also enable coverage in the test target configuration.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Coverage shows which code was exercised; a high percentage does not establish that tests check meaningful behavior. Use the report to find untested areas, then decide whether additional assertions would protect important outcomes.
Keep or migrate an existing Karma project?
Karma remains supported, and Angular maintains a guide for Karma with Jasmine. A project does not need to migrate just because new CLI projects now use Vitest. Consider migration when the benefits justify reviewing the test builder, project-specific settings, and test patterns.
Angular explicitly describes migration of an existing project to Vitest as experimental. The migration guide requires the application build system. It adds Vitest and a DOM emulator, changes the test builder to @angular/build:unit-test, and may require moving test-specific build settings because the new builder does not accept all old Karma builder options in the same place.
Migration checks
-
Audit custom
karma.conf.jssettings before removing or replacing the file.Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Review test-specific build options and move settings as required by the new builder.
-
The refactoring schematic can transform common Jasmine patterns, but it does not install dependencies, change the builder, move build options, remove old files, or cover complex and nested spy scenarios.
Rank #4
SaleUGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
-
Review schematic changes and run the full suite after migration; do not assume transformed tests are correct without checking their behavior.
-
Existing Zone-based helpers can be patched, but Angular recommends planning a transition toward native async code and Vitest fake timers.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
For project-specific steps, follow Angular’s Vitest migration guide alongside its testing overview. Because the migration is experimental, validate the instructions against the Angular documentation and the builder configuration used by your project.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshoot common test failures
-
ng testis not recognized: Run it from the workspace root and confirm the Angular CLI is available to the project. Check that the workspace defines a test target inangular.json. -
Tests keep running or CI hangs: Interactive mode watches files. Set
CI=true, or useng test --no-watch --no-progresswhere CI does not provide that variable. -
A DOM or browser API is missing: The default environment emulates the DOM, so it may not provide the browser-specific behavior your test needs. Use a supported browser provider for tests that require browser APIs or rendering fidelity.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
-
An HTTP test waits indefinitely or fails verification: Check that the test made the expected request, flush its response, and verify there are no outstanding requests. The test backend does not call the real service endpoint.
-
Migration produces builder or configuration errors: Confirm the project uses the application build system, inspect the new unit-test builder options, and move or remove settings that belonged only to the Karma builder. Review custom Karma configuration before cleanup.
-
A migrated spy or asynchronous test behaves differently: The schematic does not cover every complex spy pattern. Inspect transformed tests, simplify nested spy setups where possible, and plan replacement of Zone-based helpers with native async patterns or Vitest fake timers.
-
Coverage does not run: Confirm
@vitest/coverage-v8is installed, then runng test --coverage.Recommended Free Tools
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Or skip the browser setup
If what you need is a screenshot of a website as part of a workflow, an API can replace browser automation for the capture itself. ScreenshotNeo’s one-call endpoint returns an image or PDF, with options documented at the ScreenshotNeo API documentation.
Quick Recap
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides screenshot tools for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




