Skip to content

feat(cli): add --repeats to the cli options - #9250

Closed
michael-debs wants to merge 4 commits into
vitest-dev:mainfrom
michael-debs:issue/7352
Closed

michael-debs wants to merge 4 commits into
vitest-dev:mainfrom
michael-debs:issue/7352

Conversation

@michael-debs

@michael-debs michael-debs commented Dec 14, 2025 •

Copy link
Copy Markdown
Contributor

Description

This pull request exposes the repeat option of the test options to the cli

image

it will prioritize the test option value over the cli value for an individual test.
so if your code was:

test("bar() to return bar", async () => {
  expect(await bar()).toBe('bar')
})


test("1 + 1 = 2", { repeats: 10 }, () => {
  expect(1 + 1).toBe(2)
})

it will output:
image

Resolves #7352

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify

netlify Bot commented Dec 14, 2025

Copy link
Copy Markdown

✅ Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit cff87b7
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/693ec7011a765d00089e7bda
😎 Deploy Preview https://deploy-preview-9250--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@michael-debs
michael-debs marked this pull request as ready for review December 14, 2025 17:24
const $ = runner.trace!

const repeats = test.repeats ?? 0
const repeats = (test.repeats || runner.config.repeats) ?? 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const repeats = (test.repeats || runner.config.repeats) ?? 0
const repeats = test.repeats ?? runner.config.repeats ?? 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I would add it somewhere here:

repeats: options.repeats,

So that testCase.options.repeats is not 0

Comment thread docs/config/repeats.md
- **Default:** `0`
- **CLI:** `--repeats=<number>`

Repeat the test a specific number of times regardless of the result.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Repeat the test a specific number of times regardless of the result.
Repeat every test a specific number of times regardless of the result.

- **CLI:** `--repeats <number>`
- **Config:** [repeats](/config/repeats)

Repeat the test a specific number of times regardless of the result (default: `0`)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Repeat the test a specific number of times regardless of the result (default: `0`)
Repeat every test a specific number of times regardless of the result (default: `0`)

argument: '<times>',
},
repeats: {
description: 'Repeat the test a specific number of times regardless of the result (default: `0`)',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: 'Repeat the test a specific number of times regardless of the result (default: `0`)',
description: 'Repeat every test a specific number of times regardless of the result (default: `0`)',

@Livan-pro

Copy link
Copy Markdown
Contributor

Looking forward to this 👀

@the-dream-machine

Copy link
Copy Markdown

This would be very useful

@hi-ogawa

Copy link
Copy Markdown
Collaborator

superseded by

@hi-ogawa hi-ogawa closed this Sep 28, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose repeats as a cli argument

5 participants