Power Your Software Testing with AI Agents and Cloud
The Native AI-Agentic Cloud Platform to Supercharge Quality Engineering. Test Intelligently and Ship Faster.
- TestMu AI (Formerly LambdaTest)
- /
- Blog
- /
- How to Perform Regression Testing From the Command Line
How to Perform Regression Testing From the Command Line
Run a regression suite from the terminal: tag and select tests, run only what changed, shard across CI jobs, rerun failures, and scale it on HyperExecute VMs.
Published on:
You change one form component and push. The pipeline starts the entire regression suite, every browser test in the repository, and the pull request waits for all of it. One test fails, passes when someone clicks re-run, and nobody can say whether the change broke anything.
Every part of that loop has a command-line answer: select the suite with tags, scope it to what changed, shard it, rerun only the failures, and catch flaky tests before they erode trust. This guide walks through each step with Playwright, pytest, Jest, and Maven, then runs a plain-English regression suite on TestMu AI's HyperExecute grid with Kane CLI.
TL;DR
To automate regression testing from the command line, tag the regression tests and select them with a filter such as npx playwright test --grep "@regression". In CI, run only changed tests on pull requests, split the suite into shards, rerun failures with --last-failed, and block the merge on the exit code. Run the full suite nightly.
- How to select regression tests in Playwright: add the @regression tag to each test with { tag: '@regression' } and run npx playwright test --grep "@regression". Adding --list previews the selection. Runs tests with --list: No.
- How to run only changed tests: Playwright's --only-changed=main runs only test files changed against main. Jest's --changedSince=main runs tests related to files changed since main.
- How to shard a Playwright suite: Playwright's --shard=2/4 runs one quarter of the suite per CI job. Tests in one file stay on one worker unless --fully-parallel is set.
- How to rerun only failed tests: Playwright's --last-failed reruns the previous run's failures. A test that passes on retry is labeled flaky. Fails the build on a flaky test by default: No, unless --fail-on-flaky-tests is set.
- How to run the suite with Kane CLI: TestMu AI's kane-cli testrun run --tags regression --remote sends tagged _test.md files to HyperExecute as one job, split across the concurrency set by --parallel. Local Chrome required: No.
The Regression Testing Loop as Commands
Running everything on every change is still the default. TestMu AI's future of quality assurance survey found that 73.8% of teams run all automation tests every time, which it ties directly to longer developer feedback times. A loop of four commands, each doing one job, cuts that feedback time without shrinking the suite.
# 1. Select 2. Scope to the change 3. Shard 4. Rerun failures
npx playwright test --grep "@regression" --only-changed=main --shard=1/4
npx playwright test --last-failed
pytest -m regression -n auto # pytest-xdist for parallel workers
pytest --lf
npx jest -t regression --changedSince=main --shard=1/4
npx jest --onlyFailures
mvn test -Dgroups=regression -Dsurefire.rerunFailingTestsCount=1The framework examples use a six-test Playwright suite that runs against TestMu AI's Selenium Playground on the TestMu AI cloud grid; the Kane CLI section uses a demo Shopify storefront. If you need a refresher on what belongs in the suite, start with regression testing and how it differs in sanity testing vs regression testing.
How to Run Only the Tests a Change Affects
Scope pull request runs to the files a change touches. The test CLI reference describes --only-changed as running only test files changed between HEAD and a ref, with uncommitted changes as the default. Jest's CLI goes further with --changedSince and --findRelatedTests, which follow imports from changed source files to the tests that cover them.
# Playwright: test files changed between HEAD and main (uncommitted changes by default)
npx playwright test --only-changed=main
# Jest: tests related to files changed since main, or to named source files
npx jest --changedSince=main
npx jest --findRelatedTests src/cart/total.tsOn a feature branch that edits only the dropdown test, Playwright runs that one file, three of the six regression tests:
$ git diff --stat main
tests/widgets.spec.ts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
$ npx playwright test --only-changed=main
Running 3 tests using 1 worker
ok 1 tests/widgets.spec.ts:3:5 › radio button reports the chosen value @regression (1.9s)
ok 2 tests/widgets.spec.ts:13:5 › select dropdown shows the selected day @regression (996ms)
ok 3 tests/widgets.spec.ts:19:5 › table lists the Tokyo office @regression (1.1s)
3 passed (20.7s)File-level selection misses a shared helper or a backend change that no test file imports, so treat it as the pull request gate and keep a full nightly run as the safety net. Deciding what a change can reach is its own discipline, covered in impact analysis in testing.
How to Rerun Failures and Catch Flaky Tests
Flaky tests are a measurable cost. The same TestMu AI survey found teams spend 7.8% of their time fixing flaky tests, and that 58% of teams see more than 1% of their test runs come back flaky. On the command line, rerun only what failed, then measure whether a failure repeats.
When a full run fails one test, fix it and pass --last-failed to rerun only that test instead of all six:
$ npx playwright test --grep "@regression"
ok 2 tests/widgets.spec.ts:3:5 › radio button reports the chosen value @regression (1.6s)
...
1) tests/forms.spec.ts:3:5 › single input echoes the message @regression @smoke
1 failed
5 passed (39.3s)
$ npx playwright test --last-failed
Running 1 test using 1 worker
ok 1 tests/forms.spec.ts:3:5 › single input echoes the message @regression @smoke (1.4s)
1 passed (14.8s)To check whether a failure is flaky, repeat the test with one retry allowed. Playwright's test retries guide defines a flaky test as one that fails first and passes on retry, and the run shows the trap: one flaky result, and still exit code 0.
$ npx playwright test --grep radio --repeat-each 8 --retries 1
ok 1 tests/widgets.spec.ts:3:5 › radio button reports the chosen value @regression (1.6s)
...
ok 9 tests/widgets.spec.ts:3:5 › radio button reports the chosen value @regression (retry #1) (1.6s)
1 flaky
7 passed (55.2s)
$ echo $?
0Here the cause is timing: the page's button handler attaches after the script loads, so an early click does nothing. Clicking the label instead still fails four of eight repeats, and waiting for network idle passes but is discouraged in Playwright's docs. Retrying the whole interaction inside expect().toPass() passes eight of eight:
test('radio button reports the chosen value', { tag: '@regression' }, async ({ page }) => {
await page.goto('radiobutton-demo/');
// The button responds only after the page's script loads, so retry the interaction until it does.
await expect(async () => {
await page.getByRole('radio', { name: 'Male' }).first().check();
await page.getByRole('button', { name: 'Get value', exact: true }).click();
await expect(page.getByRole('main')).toContainText("'Male' is checked", { timeout: 1_000 });
}).toPass({ timeout: 15_000 });
});pytest --lf # only the last failures
pytest --ff # failures first, then everything else
npx jest --onlyFailures
mvn test -Dsurefire.rerunFailingTestsCount=2 # reruns in the same build, reports "Flakes: N"Maven behaves like Playwright here: its rerun failing tests option reports a test that passes on rerun as a flake and still marks the build successful. Count the flakes in CI, or they stay invisible.
Gating the Regression Suite in CI
The workflow below combines the earlier steps: changed tests on each pull request, the full suite nightly, four shards, one retry, and a hard failure on flaky results. Per the workflow syntax reference, fail-fast defaults to true in a matrix, which cancels in-progress shards the moment one fails; set it to false so every shard reports.
name: regression
on:
pull_request:
schedule:
- cron: '0 2 * * *' # full suite every night
jobs:
regression:
runs-on: ubuntu-latest
strategy:
fail-fast: false # the default (true) cancels the other shards on one failure
matrix:
shard: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # --only-changed needs the base branch history
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
- name: Changed tests (pull requests)
if: github.event_name == 'pull_request'
env:
LT_USERNAME: ${{ secrets.LT_USERNAME }}
LT_ACCESS_KEY: ${{ secrets.LT_ACCESS_KEY }}
run: >
npx playwright test --grep "@regression"
--only-changed=origin/${{ github.base_ref }}
--shard=${{ matrix.shard }}/4 --retries=1 --fail-on-flaky-tests
- name: Full regression suite (nightly)
if: github.event_name == 'schedule'
env:
LT_USERNAME: ${{ secrets.LT_USERNAME }}
LT_ACCESS_KEY: ${{ secrets.LT_ACCESS_KEY }}
run: npx playwright test --grep "@regression" --shard=${{ matrix.shard }}/4 --retries=1- Exit code as the gate - Playwright, pytest, Jest, and Maven all exit non-zero on a failed test, so a required status check blocks the merge with no report parsing.
- Flaky results block on PRs only - --fail-on-flaky-tests on pull requests forces a fix; the nightly run records flakes without blocking anything.
- Same pattern for mobile - the matrix, secrets, and exit-code gate carry over to device runs, as shown in mobile app testing command line.
- Full user journeys - starting the app, saving a login, and keeping traces for a checkout flow are covered in end-to-end testing command line.
How to Run Regression Tests With Kane CLI
If the regression suite is written as plain-English tests instead of code, Kane CLI runs it with the same select, parallelize, and fail-fast controls as the frameworks above. Each test is a _test.md file: YAML front matter carries the tags, and every ## heading is one step with its objective in plain English.
The first run authors each step with the agent. Every later run replays the recording, and that rerun of unchanged tests against a changed application is the regression check.
The walkthrough uses the Shopify storefront from the theme update smoke use case, a change that can break buying without anyone noticing. A theme is published in admin, the storefront is checked for the new theme, and the buyer path is walked to checkout.
Two sibling tests from the same storefront, checkout extension render and discount code application, share the regression tag and make the folder a suite. The commands and output shown are from Kane CLI 0.8.18 on Windows 11; the same commands run unchanged on macOS and Linux.
Step 1: Install Kane CLI and Log In
Install the @testmuai/kane-cli package from npm, confirm the version, and log in once. Web runs also need Google Chrome installed; Kane CLI launches and drives it itself. Full setup steps are in the Kane CLI getting started docs.
npm install -g @testmuai/kane-cli
kane-cli --version
kane-cli login0.8.18Step 2: Create the Suite as Tagged Test Files
Create a project folder with a tests/shopify/ directory. Each test is a Markdown file whose name ends in _test.md; the tags list in the front matter is what testrun selects on, so the theme test sits in both the smoke subset and the regression suite.
kane-regression\
tests\shopify\
theme-update-smoke_test.md # tags: [regression, smoke]
checkout-extension-render_test.md # tags: [regression]
discount-code-application_test.md # tags: [regression]Save this as tests/shopify/theme-update-smoke_test.md. The four steps are the published use case's, with the store address moved into a variable: confirm the live theme, publish a different one, verify the storefront reflects it, and reach checkout.
---
mode: testing
tags: [regression, smoke]
variables:
store_url: "https://my-testing-repo-main.vercel.app/shopify-clone-app"
---
# Theme update smoke
## Confirm the live theme
Open {{store_url}}/admin?reset=true, click "Themes", and verify the themes list shows "Dawn" marked "Live".
## Publish a different theme
Click "Publish" on "Refresh", then click "Publish theme" in the confirmation dialog, and verify a notice appears reading "Refresh is now the live theme."
## Verify the storefront picked it up
Click "View storefront" and verify the storefront shows "Storefront is running the Refresh theme" and the product grid lists "Heavyweight Cotton Tee".
## Walk through checkout
Click "Add to cart" on "Heavyweight Cotton Tee", click "View cart", click "Checkout", and verify the checkout page renders with a "Payment" section and a "Pay" button.The other two files follow the same shape. checkout-extension-render_test.md reaches checkout and verifies the extension block, a custom field, and an upsell line item without breaking payment; discount-code-application_test.md rejects an invalid code, applies a ten percent code, and verifies the discounted total. Write each step as something visible on screen, and reference values through {{variables}} so the same file runs against staging and production.
Confirm Kane CLI discovers all three:
kane-cli testmd listStep 3: Preview the Selection With a Dry Run
A dry run resolves the tag filter, validates every file's front matter, and prints the plan without opening a browser. It does the job --list does in Playwright: a typo in a tag shows up here as zero tests, not as a green pipeline that ran nothing.
kane-cli testrun run --tags regression --dry-runtestrun: testrun 3 paths
parallel=1 on-failure=continue
+ tests/shopify/theme-update-smoke_test.md
+ tests/shopify/checkout-extension-render_test.md
+ tests/shopify/discount-code-application_test.md
3 test(s) selected - plan validWith no path, testrun run discovers every _test.md under the project and --tags filters them; a folder path is rejected. Swap --tags regression for --tags smoke and only the theme test is selected, and --match <regex> filters on file path instead of tags.
Step 4: First Run, Every Step Authored
Run the suite with three parallel workers. On the first run there is no recording yet, so the agent authors each step: it reads the page, decides how to satisfy the objective, and records what it did. This is the slow run.
kane-cli testrun run --tags regression --parallel 3
Each member shows authoring while the agent writes its steps. In this run the summary reads 3 passed and 2 authored: the theme test already had a recording from an earlier run, so it replayed, and the whole suite finished in 5m 48s. Each test gets an output-<name>/ folder next to it with Result.md and the recording in .internal/ that later runs replay, and the suite's sealed evidence pack lands in .testmuai/evidence/.
Step 5: Rerun After the Change, Steps Replay
Push the next theme, or deploy the next build, and rerun a test whose file did not change. Nothing in the test file changed, so every step starts from its recording against the new application state:
kane-cli testmd run tests/shopify/theme-update-smoke_test.md
echo $? # PowerShell: $LASTEXITCODE cmd: echo %ERRORLEVEL%
The breakdown reads 4 replay and 0 author, and the exit code is 0. The rerun still took 254 seconds, because the recorded path for step 4 missed on the new page state: adaptive heal re-authored that one step, marked retry-promoted, and the run passed without re-authoring the other three.
Adaptive heal applies when a page changes in a way that breaks the recorded path but not the objective: it re-authors only the failing tail, up to three attempts, before a full re-author. If the change did break something, a step whose assertion no longer holds fails with a Reason: line and its screenshot, and the exit code is 1.
For the whole suite, rerun kane-cli testrun run --tags regression --parallel 3 the same way, and add --on-failure fail-fast to stop dispatching new members after the first failure.
Step 7: Run the Suite on HyperExecute and Gate It in CI
The same command runs on the HyperExecute grid with --remote. Install the plugin once, then Kane CLI zips the project, dispatches it, runs each member as kane-cli testmd run on a grid runner, and downloads the recordings and evidence pack back into the project. Nothing but Node and the plugin is needed on the machine that dispatches, so this is the form that runs in a pipeline.
kane-cli plugin install remote-execution
kane-cli plugin doctor remote-execution
kane-cli testrun run --tags regression --remote --parallel 3 --dry-run
kane-cli testrun run --tags regression --remote --parallel 33 test(s) selected - plan valid
remote testrun · hyper · env prod · dispatching…
Job Link: https://hyperexecute.lambdatest.com/hyperexecute/task?jobId=<job id>
✔ [1] setup-runtime (19s)
✔ [1] pre (28s)
✔ [1] discovery (1s)
✔ [1] tests/shopify/theme-update-smoke_test.md (21s)
✔ [2] tests/shopify/checkout-extension-render_test.md (18s)
✔ [3] tests/shopify/discount-code-application_test.md (16s)
Downloading artifacts...
Final Job Status: Completed
testrun : passedIn CI, gate on the exit code the same way as any other framework in this guide: 0 passed, 1 a failed step, 2 a preflight error. A GitHub Actions job needs only the two secrets and one step:
- name: Regression suite on HyperExecute
env:
LT_USERNAME: ${{ secrets.LT_USERNAME }}
LT_ACCESS_KEY: ${{ secrets.LT_ACCESS_KEY }}
run: |
npm install -g @testmuai/kane-cli
kane-cli plugin install remote-execution
kane-cli testrun run --tags regression --remote --parallel 3 \
--username "$LT_USERNAME" --access-key "$LT_ACCESS_KEY"Run the smoke tag on every pull request and the full regression tag nightly, the same pull request and nightly split as the Playwright workflow above. Each run seals an evidence pack with step screenshots, network logs, and console output, so a failed regression test arrives with its proof attached.
The three storefront tests, with their test.md and command, are published as Kane CLI use cases: theme update smoke, checkout extension render and discount code application. For the replay and re-author rules see Introducing test.md, and for the pipeline side see Kane CLI is CI/CD ready.
Note: Run the tagged regression suite on HyperExecute with kane-cli testrun run --remote and your TestMu AI credentials. Sign up for free.
Troubleshooting Command-Line Regression Runs
Each row pairs a symptom you will see in the output with its usual cause and fix. With --remote, the Job Link in the Kane CLI output opens the HyperExecute job with each member's log.
| Symptom | Likely cause | Fix |
|---|---|---|
| "option '--grep <grep>' argument missing" | PowerShell consumed the unquoted @tag | Quote it: --grep "@regression" |
| --only-changed errors in CI | The shallow clone has no base branch to compare against | fetch-depth: 0 and compare against origin/<base> |
| Each shard runs on one worker | Tests in one file stay on one worker by default | --fully-parallel, or split large spec files |
| A flaky test passes the pipeline | Flaky results still exit 0 | --fail-on-flaky-tests on pull requests |
| The Kane CLI dry run selects zero tests | The tag is misspelled or missing from the file's front matter | Run kane-cli testmd list, which shows each file's tags |
| Every Kane CLI step re-authors on each CI run | The output-<name>/ folder holding the recordings was not committed | Commit output-<name>/ next to each _test.md |
| "not a *_test.md file" from testrun run | A folder path was passed; testrun run takes files or no path | Drop the path and select with --tags regression |
Conclusion
Start by tagging the tests that guard released behavior and running npx playwright test --grep "@regression" --list to confirm the selection. Then add --only-changed to pull requests, shard the nightly run, and turn on --fail-on-flaky-tests once the suite is stable.
For tests written in plain English, save them as tagged _test.md files and run them on HyperExecute with kane-cli testrun run --remote, where every replay after the first run is the regression check. For deciding which tests earn a place in the suite, see automated regression testing.
Author
Japneet Singh Chawla is an Engineering Manager at TestMu AI (formerly LambdaTest), where he leads a team driving HyperExecute, the AI-native Test Orchestration Cloud Platform, and integrations with Cypress, Provar, Tosca, and Selenium, improving test execution efficiency and driving adoption across 500+ enterprise clients. He also spearheaded zero-downtime deployments that cut release-related downtime by 90%, and mentors new engineers into productive contributors. He brings 9+ years of experience building and scaling distributed systems, SaaS platforms, and developer tools, with deep hands-on backend engineering across Golang, Python, Node.js, Kafka, and Redis. Earlier at Sumo Logic he built award-winning developer tools, including a VS Code Parser Linter, and at Indus Valley Partners he was a founding member of the Sentiment Analyzer team, building ML-powered solutions for financial clients. Japneet holds an MCA in Computer Science from GGSIPU.
Reviewer
Anmol Gupta is Vice President of Product Management at TestMu AI (formerly LambdaTest), driving HyperExecute, the test orchestration cloud that runs and accelerates automated test execution. He led the development of the Unified Test Execution Cloud Platform and now leads a 30-member cross-functional product organization across product lines contributing $7M+ in revenue. He brings over nine years of experience and previously co-founded the SaaS company Timble as CTO, where he grew the team from 5 to 40 and launched an AI KYC platform that processed 600K+ applications in five months while cutting verification time from 12 minutes to under 30 seconds. Anmol holds an MTech and BTech from IIT Delhi.
Regression Testing CLI FAQs
Did you find this page helpful?
More Related Blogs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance
- Advanced access controls
- Advanced data retention rules
- Advanced Local Testing
- Premium Support options
- Early access to beta features
- Private Slack Channel
- Unlimited Manual Accessibility DevTools Tests








