To write and run Cypress tests, install Cypress in your JavaScript project, choose end-to-end (E2E) or component testing in its first-run Launchpad, add an independent spec, and use cypress open while developing and cypress run for terminal or CI runs. The two modes are complementary: you can use either or both as your project needs.
Install Cypress in your project
From the project root, use the package manager the project already uses. For npm:
npm install cypress --save-dev
Equivalent commands for other package managers are:
yarn add cypress --devpnpm add --save-dev cypressbun add --dev cypress
Cypress normally downloads its matching binary during the package’s postinstall step. If your environment blocks package lifecycle scripts or you intentionally defer the binary download, install it separately with cypress install. See the Cypress installation guide and CLI reference for installation details.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11#1 Best Overall
- 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.
Choose E2E or component testing and complete setup
Launch Cypress from the project root:
npx cypress open
Use the equivalent command for your package manager where appropriate: yarn cypress open, pnpm cypress open, or bunx cypress open. On first launch, Cypress opens the Launchpad, which guides you through choosing a testing type, selecting a browser, and creating or configuring the files for that mode.
Choose the mode that matches what you want to verify
- E2E testing: Exercise the application as a user would, across its running interface and relevant application flows.
- Component testing: Mount and test a component in a browser as an individual unit of the interface.
Selecting one mode does not prevent you from adding the other later. Cypress’s Open the app guide explains the Launchpad flow.
Know where configuration and support code go
The generated structure typically includes cypress.config.js, a fixtures directory, and a support file: cypress/support/e2e.js for E2E or cypress/support/component.js for component testing. Cypress loads the corresponding support file before the selected spec. Put genuinely global setup or hooks there; keep spec-specific or heavy imports in the spec that needs them. These are defaults, not fixed requirements—the structure can be reconfigured.
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.
For a repeatable team workflow, you can add a descriptive script such as cy:open to package.json. Avoid naming the script cypress, which can conflict with Yarn command resolution.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Write a focused, independent spec
Cypress specs are JavaScript test files. For example, a basic E2E spec that checks for a visible home-page heading could look like this:
describe('home page', () => {
it('shows the main heading', () => {
cy.visit('/')
cy.get('h1').should('be.visible')
})
})
This is an illustrative pattern: / assumes your app serves its home page there, and the heading assertion must match your interface. Use selectors and assertions that make sense for the application and check an outcome a user can observe.
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.
Keep tests independent
Set up each test so it can run by itself and in a different order. A test that relies on state left by another can fail when a test is skipped, reordered, or run alone. Cypress’s writing and organizing tests guide explains the expected independence between tests.
Keep data handling appropriate to the data
- Use a fixture for known, static data you keep in the project. Fixtures can also provide stubbed network responses.
- For example, stub a users endpoint with
cy.intercept('GET', '/api/users', { fixture: 'users.json' }). - If you create or change a file during the test and need to read its current contents, use
cy.readFile(); fixtures are cached. - For large files or work that needs Node.js, use
cy.task(). - If generating tests from records, import the data statically so the
it()cases exist when Cypress loads the spec.
Run tests locally
| Command | Best for | Behavior |
|---|---|---|
npx cypress open |
Writing and debugging | Opens Cypress’s interactive browser workflow. It watches spec changes and reruns the active spec; the Command Log and test-step history help inspect a run. |
npx cypress run |
Repeatable terminal runs | Runs tests to completion and is headless by default. |
These workflows complement one another: use open mode for the edit-and-debug loop, then run mode for a check that completes without the interactive workflow. Cypress describes its interactive workflow and test watching in its open mode guide.
Recommended Free Tools
Focus a spec or choose a browser and configuration
To run one spec from the terminal:
npx cypress run --spec "cypress/e2e/my-spec.cy.js"
You can also select a browser with --browser or a configuration file with --config-file. Check that a selected spec path also matches the project’s configured specPattern. The Cypress CLI reference documents command options.
Rank #4
- 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
Run Cypress in CI
Install Cypress and invoke its run command from your CI provider’s job configuration. If the tests visit an application server started by that job, wait until the server’s URL responds before starting Cypress. Starting the server and Cypress together without a readiness check creates a race: Cypress may run before the app is ready. Cypress’s CI guide notes that there is no guarantee the server has booted by the time cypress run executes.
Make readiness explicit
Use a readiness utility or the Cypress GitHub Action’s documented start and wait-on options. Do not rely on an arbitrary sleep: a fixed delay can waste time when the app starts quickly and still be too short when it starts slowly. Keep the CI job’s launch, readiness check, and test command in a clear sequence.
Protect secrets in CI
Use your CI provider’s secret-management facility for credentials and other sensitive values. Cypress warns that secrets passed as CLI arguments may appear in CI logs, so avoid exposing them in command lines or output.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
- 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.
Troubleshoot common Cypress test problems
- Cypress visits the app before it is available: Add a URL readiness check before
cypress run; do not assume the server is ready just because its start command was launched. - A test fails when run alone or in a different order: Remove dependencies on leftover browser or application state and make the test’s setup explicit.
- A selected spec does not run: Verify the file path in
--specand confirm it matches the configuredspecPattern. - A test reads stale fixture contents: Fixtures are cached. Use
cy.readFile()for a changing or app-created file. - A CI log exposes a sensitive value: Move the value into the CI provider’s secret management rather than passing it as a command-line argument.
Or skip the browser setup
If your goal is to capture a website screenshot rather than test application behavior, ScreenshotNeo offers a one-request screenshot API. It is separate from Cypress, not a Cypress test runner. This cURL example saves a WebP capture of Stripe:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for the request options. Before capture, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.
Frequently Asked Questions
Can I use both Cypress E2E and component testing in one project?
Yes. You can start with either testing type and add the other later.
Does Cypress run tests in a browser in headless mode by default?
The terminal command cypress run is headless by default; cypress open is the interactive workflow.
Quick Recap
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.

