Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Cypress Component Testing to mount an Angular component in a real browser, provide the inputs and dependencies it needs, then interact with its rendered UI and assert what a user can see. First confirm your Angular version is supported: Cypress’s current Angular overview lists Angular ^21.0.0 and ^22.0.0.

Check Angular compatibility and prerequisites

Cypress’s Angular overview currently lists support for Angular ^21.0.0 and ^22.0.0. These ranges are version-sensitive; check the current Cypress Angular overview before setting up a project on another Angular version.

  • The Cypress Angular harness requires @angular-devkit/build-angular, including in projects that use @angular/build.
  • As of Cypress 16, the harness supports zoneless testing without additional configuration or zone.js. The overview notes that zoneless is the default in Angular 21 and 22.

Use Cypress’s official Angular Component Testing overview for the current compatibility and setup details. Its Component Testing setup starts a development server to compile and serve the specs; it does not visit your deployed production or staging application.

Install Cypress and configure Component Testing

  1. From your Angular project directory, install Cypress as a development dependency: npm install --save-dev cypress. Use the equivalent development-dependency command for your package manager if the project uses something other than npm.

    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.
  2. Open the Cypress app with npx cypress open.

  3. Choose Component Testing. Cypress says its app detects an Angular CLI project and configures the component-testing setup. Follow the app’s prompts to select the browser and complete configuration.

  4. Create a component spec, for example stepper.component.cy.ts, alongside or in the spec location your project uses. Import the component using a path valid from that file.

The precise generated configuration depends on the project. Prefer the Angular configuration Cypress generates over copying a generic setup into every project: standalone components and NgModule-based components do not have identical dependency setup needs.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.

Mount a component and test what it renders

A minimal Cypress component test imports the component and calls cy.mount():

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { StepperComponent } from './stepper.component'

describe('StepperComponent', () => {
  it('mounts', () => {
    cy.mount(StepperComponent)
  })
})

Run the spec in the Cypress Component Testing runner. Cypress’s mount() API yields a wrapper that includes the component and its Angular fixture. Once mounted, select rendered elements, perform the same kinds of interactions a user would, and assert the resulting UI.

Cypress Documentation describes Component Testing as mounting components “directly in a real browser — not a simulated DOM.” That makes it useful for checking browser-rendered templates and interactions. It does not mean one component test replaces class-level tests or end-to-end tests; choose the test scope based on the behavior you need to verify.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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.

Provide inputs, providers, and imports

Set initial component properties

Pass values using the componentProperties mount option. This is useful when a component’s rendered state depends on an input or other property. For example, adapt the property name to the component:

cy.mount(StepperComponent, {
  componentProperties: {
    count: 3,
  },
})

For a legacy @Input() that the test needs to change after mounting, Cypress’s examples use fixture.componentRef.setInput(...). This lets Angular process the input change and run change detection correctly:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
cy.mount(StepperComponent).then(({ fixture }) => {
  fixture.componentRef.setInput('count', 5)
  fixture.detectChanges()
})

Use the actual input name and the component’s expected value type. Then assert the changed, user-visible output rather than relying only on the internal property value.

Rank #4
Sale
UGREEN 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

Supply collaborators where the component needs them

For components that depend on providers, declarations, or imports, configure the relevant mount options. The required setup depends on the Angular project style and the component’s dependencies; do not assume a single provider or module configuration fits every component.

Standalone components carry their imports in their own component metadata, so many can be mounted directly. Cypress’s examples note that mount options such as declarations and imports do not apply to standalone components in the same way they do to other component setups. If mounting fails because Angular cannot resolve a dependency, check the component’s metadata and provide the missing collaborator in the appropriate place.

Test outputs and signal-based inputs

Assert output events with a spy

Pass a Cypress spy as an output property, trigger the UI action that emits the event, and assert that the spy received the expected value. Cypress’s Angular examples also provide createOutputSpy() for this pattern.

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.
const changed = cy.spy().as('changed')

cy.mount(StepperComponent, {
  componentProperties: {
    changed,
  },
})

cy.get('button').click()
cy.get('@changed').should('have.been.calledWith', 1)

Replace changed, the button selector, and the expected value with the component’s actual output name and behavior. Prefer a selector and assertion that represent the interaction and result the user cares about.

Use writable signals when changing a bound value

Cypress’s examples cover Angular input and model signals. Plain values are suitable for initial values; if the test needs to change a bound value after mounting, use a writable signal so the test can update it. Match the signal type and binding to the component’s actual API rather than treating a signal like a legacy input property.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose the right testing layer

Test scope Environment Best fit
Class-only test No DOM is needed for the behavior being checked. Validate logic that does not depend on template rendering or browser interaction. Angular notes these tests can be simpler for such behavior.
Cypress component test A component mounted in a real browser. Check rendered output, user interaction, and the component’s browser-visible behavior with its relevant dependencies.
End-to-end test The larger application flow. Check behavior that depends on integration across the application rather than a single mounted component.

Angular’s testing guide describes a component as its template and class working together. DOM tests help verify rendering, responses to user input, and integration with parent and child components. For behavior that does not need a DOM, a class-only test may be enough. Use both component and broader application tests when their different scopes matter; component testing is not a substitute for every other test layer.

Troubleshoot common setup and test failures

  • The project or component-testing setup is not detected: Confirm you opened Cypress from the Angular project directory and selected Component Testing. Check the current Cypress Angular overview for supported Angular versions.
  • The Angular builder cannot be resolved: The Cypress Angular harness requires @angular-devkit/build-angular, even when the project uses @angular/build. Check the project’s installed dependencies and build configuration.
  • A component fails to mount because an import or provider is missing: Review the component’s dependencies. Add the required providers or imports using the mount configuration appropriate to the project style; for a standalone component, first check its own metadata.
  • An input change does not appear in the rendered UI: For a legacy @Input() changed after mount, use fixture.componentRef.setInput() and allow Angular change detection to run. For a signal-based bound value that must change, use a writable signal.
  • An output assertion never fires: Check that the spy is passed to the actual output property, that the test triggers the action that emits it, and that the expected argument matches the emitted value.
  • A zoneless setup expects zone.js: Cypress 16 and later supports zoneless testing without extra configuration or zone.js; confirm the project and Cypress versions against the current Angular overview before changing project-wide settings.

Or skip the browser setup

ScreenshotNeo is a website screenshot API, not an Angular component-test runner; use Cypress above to exercise component behavior. If your separate goal is to capture a page screenshot, one GET request can return an image or PDF. The example below saves a WebP screenshot; see the ScreenshotNeo API documentation for options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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 as 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 and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

Sign up for ScreenshotNeo’s free plan to try it without a card.

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.