Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: feat: repeats as CLI command #7569

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/vitest/src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export const configDefaults: Readonly<{
}
slowTestThreshold: number
disableConsoleIntercept: boolean
repeats: number
}> = Object.freeze({
allowOnly: !isCI,
isolate: true,
Expand Down Expand Up @@ -166,4 +167,5 @@ export const configDefaults: Readonly<{
},
slowTestThreshold: 300,
disableConsoleIntercept: false,
repeats: 0,
})
4 changes: 4 additions & 0 deletions packages/vitest/src/node/cli/cli-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,10 @@ export const cliOptionsConfig: VitestCLIOptions = {
'Threshold in milliseconds for a test or suite to be considered slow (default: `300`)',
argument: '<threshold>',
},
repeats: {
description: 'Number of times to repeat each test',
argument: '<repeats>',
},
teardownTimeout: {
description:
'Default timeout of a teardown function in milliseconds (default: `10000`)',
Expand Down
2 changes: 2 additions & 0 deletions packages/vitest/src/node/config/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@
mode,
} as any as ResolvedConfig

console.log('resolved', resolved)

Check failure on line 145 in packages/vitest/src/node/config/resolveConfig.ts

View workflow job for this annotation

GitHub Actions / Lint: node-latest, ubuntu-latest

Unexpected console statement. Only these console methods are allowed: warn, error

resolved.project = toArray(resolved.project)
resolved.provide ??= {}

Expand Down
7 changes: 7 additions & 0 deletions packages/vitest/src/node/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,13 @@ export interface InlineConfig {
*/
slowTestThreshold?: number

/**
* Number of times to repeat the tests.
* @default 0
*
*/
repeats?: number

/**
* Path to a custom test runner.
*/
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions test/fake-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "fake-test",
"version": "1.0.0",
"description": "A fake test package",
"author": "Joao Lopes",
"license": "ISC",
"keywords": [],
"main": "index.js",
"scripts": {
"test": "vitest"
},
"devDependencies": {
"vitest": "workspace:*"
}
}
7 changes: 7 additions & 0 deletions test/fake-test/test/ab.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { describe, expect, it } from 'vitest'

describe('Simple Math Test', () => {
it('should return 2 when adding 1 + 1', () => {
expect(1 + 1).toBe(2)
})
})
9 changes: 9 additions & 0 deletions test/fake-test/vitest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
environment: 'node',
files: ['test/**/*.test.ts'],

},
})
Loading