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

Compare the pull request’s base and head revisions, filter the changed paths to Cypress spec files, run those files with Cypress’s --spec option, and then run the complete suite. The targeted run can surface relevant failures sooner; the full run remains important because a code, configuration, support, or fixture change can affect specs that were not edited.

How changed-spec-first works

Git identifies files changed across the pull request; Cypress selects which of its configured specs to run. The workflow joins those jobs: calculate the full PR diff, pass matching spec paths to Cypress, and then run Cypress without a spec filter.

This is different from selecting tests based on past failures. The changed-first workflow uses Git paths in the current PR, not test history.

Check the Cypress spec pattern first

Use the spec location and pattern configured by your project, not a path copied blindly from an older example. Cypress’s specPattern determines which files count as specs, and --spec can narrow that configured set but cannot include files outside it. See Cypress test organization and spec patterns.

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.

For example, a project might use cypress/e2e/**/*.cy.{js,jsx,ts,tsx}. Another project may use a different directory or extensions. Adjust the Git path filter and the examples below to match your configuration.

GitHub Actions example

This workflow compares the PR’s base and head commit SHAs, so it covers the PR change set rather than just the latest commit. It assumes the project has an npm script named cy:run that runs Cypress, and uses the example spec pattern above.

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.
name: Cypress tests

on:
  pull_request:

jobs:
  cypress:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository history
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm

      - name: Install dependencies
        run: npm ci

      - name: Run changed Cypress specs, then the full suite
        env:
          BASE_SHA: ${{ github.event.pull_request.base.sha }}
          HEAD_SHA: ${{ github.event.pull_request.head.sha }}
        shell: bash
        run: |
          set -euo pipefail

          # Fetch explicitly so both PR revisions are available to git diff.
          git fetch --no-tags origin "$BASE_SHA" "$HEAD_SHA"

          mapfile -d '' -t changed_paths < <(git diff --name-only -z "$BASE_SHA" "$HEAD_SHA")
          specs=()

          for path in "${changed_paths[@]}"; do
            case "$path" in
              cypress/e2e/*.cy.js|cypress/e2e/*.cy.jsx|cypress/e2e/*.cy.ts|cypress/e2e/*.cy.tsx|cypress/e2e/*/*.cy.js|cypress/e2e/*/*.cy.jsx|cypress/e2e/*/*.cy.ts|cypress/e2e/*/*.cy.tsx)
                specs+=("$path")
                ;;
            esac
          done

          if ((${#specs[@]})); then
            printf 'Running %d changed spec(s) first.n' "${#specs[@]}"
            npx cypress run --spec "$(IFS=,; printf '%s' "${specs[*]}")"
          else
            echo "No changed paths matched the Cypress spec filter; skipping targeted run."
          fi

          echo "Running the complete Cypress suite."
          npm run cy:run

The sample filter handles files directly inside cypress/e2e and one nested directory. If your specs can be nested more deeply, or have other names/extensions, update the case patterns to cover the same paths accepted by your Cypress specPattern. The NUL-delimited Git output and Bash array preserve paths containing spaces; the comma-separated value supplied to --spec follows Cypress’s CLI syntax.

What the workflow does

  1. Checks out history: fetch-depth: 0 and the explicit fetch make the compared commit objects available to the job.
  2. Finds the PR change set: the two SHA values identify the base and head revisions, and git diff lists paths changed between them.
  3. Filters candidate specs: only paths matching the sample Cypress spec conventions go into the targeted run.
  4. Runs all specs afterward: npm run cy:run executes the project’s full-suite command regardless of whether the targeted step found a match.

Adapt it to your repository

Use your actual spec directory and naming rules

Change the case patterns to match your configured specPattern. A broad directory filter can accidentally pass non-spec files to Cypress; a narrow filter can miss valid specs. Keep the Git filter and Cypress configuration aligned.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

Make sure the compared commits represent the PR

The example uses github.event.pull_request.base.sha and github.event.pull_request.head.sha. If you use branch names instead, verify that the CI checkout has fetched the intended base and head refs before running git diff. Comparing only the latest commit misses earlier changes in a multi-commit PR.

Keep the full-suite command correct

Replace npm run cy:run with the command your repository uses for a complete Cypress run. For a project that runs Cypress directly, this may be npx cypress run. Keep this step after the targeted step; do not accidentally give the full-suite command the changed-spec list.

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

Using the Cypress GitHub Action instead

Cypress’s official GitHub Action supports running specs through its spec input. The current Cypress guide recommends the action’s v7 major tag and documents its setup options: Cypress GitHub Actions guide. You can use the action for the targeted and full runs, but take care that the targeted invocation receives only the filtered changed specs and that the later invocation is unfiltered. The shell-based example above makes that ordering explicit.

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

What changed-first does not guarantee

Git can tell you which files changed, but it cannot infer every test affected by those changes. Editing application code, Cypress configuration, support files, or shared fixtures may affect specs whose own files did not change. The subsequent full-suite run is therefore not redundant: it preserves broader regression coverage. A team can maintain a dependency map to select related specs, but only if that mapping is tested and kept current.

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.

Troubleshooting

  • The diff command says a revision is unknown: verify the workflow event provides the SHAs you reference and that the revisions are fetched. Keep checkout history available and fetch the required revisions before diffing.
  • No targeted specs run: inspect the Git diff output and compare its paths with the filter patterns. Check whether specs live under a different directory, are nested more deeply, or use different extensions. A PR with no changed spec files should skip the targeted run and still run the full suite.
  • Cypress reports that a selected file is not a spec: the file may not match Cypress’s configured specPattern. Align the Git filter with that pattern rather than broadening the Cypress run to arbitrary changed files.
  • Only the last commit’s specs are selected: compare base and head revisions for the PR, not a single commit against its parent.
  • A full run fails after the targeted run passes: that can indicate an affected but unchanged spec, shared state, or another suite-level interaction. The targeted result is an early signal, not proof that the rest of the suite is safe.

Or skip the browser setup

ScreenshotNeo is a separate website screenshot API, not a Cypress test runner, so it does not replace this changed-spec workflow. If you also need a standalone page capture for a CI artifact or visual check, one GET request can return an image or PDF. The API accepts cookie and consent banners, removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status. Its MCP server gives AI agents tools for screenshots, page information, and PDF capture. ScreenshotNeo has 1,000 shots per month free with no card; paid plans start at $5 for 3,000.

For example, save a page capture as WebP:

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 request options. Sign up for 1,000 free screenshots a month, with no card required.

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.