Skip to content

Commit 32bb903

Browse files
authored
refactor: rename test/cli -> test/e2e, test/core -> test/unit (#10209)
1 parent 8527a80 commit 32bb903

1,012 files changed

Lines changed: 312 additions & 310 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/agents/vitest-test-writer.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: vitest-test-writer
3-
description: "Use this agent when the user needs to write comprehensive tests for Vitest features. This includes unit tests for individual functions, integration tests for CLI functionality, and browser mode tests. The agent should be invoked when implementing new features that require test coverage, fixing bugs that need regression tests, or expanding test coverage for existing functionality.\\n\\nExamples:\\n\\n<example>\\nContext: User has just implemented a new utility function in the codebase.\\nuser: \"I just added a new parseConfig function to the config package\"\\nassistant: \"I see you've added a new function. Let me use the vitest-test-writer agent to create comprehensive tests for it.\"\\n<commentary>\\nSince a new function was added, use the Task tool to launch the vitest-test-writer agent to write unit tests in test/core.\\n</commentary>\\n</example>\\n\\n<example>\\nContext: User is working on a CLI feature.\\nuser: \"Please add a --json flag to the list command\"\\nassistant: \"I'll implement the --json flag for the list command.\"\\n<function call to implement the feature>\\nassistant: \"Now let me use the vitest-test-writer agent to write integration tests for this new CLI flag.\"\\n<commentary>\\nSince a CLI feature was implemented, use the Task tool to launch the vitest-test-writer agent to write integration tests in test/cli using runInlineTests.\\n</commentary>\\n</example>\\n\\n<example>\\nContext: User wants to ensure a feature works in both normal and browser modes.\\nuser: \"Can you write tests for the new snapshot feature?\"\\nassistant: \"I'll use the vitest-test-writer agent to write comprehensive tests for the snapshot feature, covering both normal and browser modes.\"\\n<commentary>\\nSince the feature needs testing in multiple modes, use the Task tool to launch the vitest-test-writer agent to write tests in test/cli (for features supporting both modes).\\n</commentary>\\n</example>"
3+
description: "Use this agent when the user needs to write comprehensive tests for Vitest features. This includes unit tests for individual functions, integration tests for CLI functionality, and browser mode tests. The agent should be invoked when implementing new features that require test coverage, fixing bugs that need regression tests, or expanding test coverage for existing functionality.\\n\\nExamples:\\n\\n<example>\\nContext: User has just implemented a new utility function in the codebase.\\nuser: \"I just added a new parseConfig function to the config package\"\\nassistant: \"I see you've added a new function. Let me use the vitest-test-writer agent to create comprehensive tests for it.\"\\n<commentary>\\nSince a new function was added, use the Task tool to launch the vitest-test-writer agent to write unit tests in test/unit.\\n</commentary>\\n</example>\\n\\n<example>\\nContext: User is working on a CLI feature.\\nuser: \"Please add a --json flag to the list command\"\\nassistant: \"I'll implement the --json flag for the list command.\"\\n<function call to implement the feature>\\nassistant: \"Now let me use the vitest-test-writer agent to write integration tests for this new CLI flag.\"\\n<commentary>\\nSince a CLI feature was implemented, use the Task tool to launch the vitest-test-writer agent to write integration tests in test/e2e using runInlineTests.\\n</commentary>\\n</example>\\n\\n<example>\\nContext: User wants to ensure a feature works in both normal and browser modes.\\nuser: \"Can you write tests for the new snapshot feature?\"\\nassistant: \"I'll use the vitest-test-writer agent to write comprehensive tests for the snapshot feature, covering both normal and browser modes.\"\\n<commentary>\\nSince the feature needs testing in multiple modes, use the Task tool to launch the vitest-test-writer agent to write tests in test/e2e (for features supporting both modes).\\n</commentary>\\n</example>"
44
model: opus
55
color: green
66
---
@@ -13,9 +13,9 @@ You write comprehensive, high-quality tests that follow the established patterns
1313

1414
## Test Location Rules
1515

16-
- **Unit tests**: Place in `test/core/`. These test individual functions by importing them directly, regardless of which package defines them.
17-
- **Integration tests**: Place in `test/cli/`. These test CLI functionality and features that require running Vitest as a process.
18-
- **Browser mode tests**: Place in `test/browser/`. However, if a feature supports both normal tests AND browser tests, place the tests in `test/cli/`.
16+
- **Unit tests**: Place in `test/unit/`. These test individual functions by importing them directly, regardless of which package defines them.
17+
- **Integration tests**: Place in `test/e2e/`. These test CLI functionality and features that require running Vitest as a process.
18+
- **Browser mode tests**: Place in `test/browser/`. However, if a feature supports both normal tests AND browser tests, place the tests in `test/e2e/`.
1919

2020
## Testing Patterns You Must Follow
2121

@@ -51,15 +51,15 @@ To ensure all tests actually passed (not just that they ran), use `testTree` or
5151

5252
## Writing Unit Tests
5353

54-
For unit tests in `test/core/`:
54+
For unit tests in `test/unit/`:
5555
1. Import the function directly from its source package
5656
2. Test pure functionality without process spawning
5757
3. Cover edge cases, error conditions, and typical usage
5858
4. Use descriptive test names that explain the scenario
5959

6060
## Writing Integration Tests
6161

62-
For integration tests in `test/cli/`:
62+
For integration tests in `test/e2e/`:
6363
1. Use `runInlineTests` to define test scenarios
6464
2. Create realistic test file content
6565
3. Validate both stderr and the test results structure

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
* text=auto eol=lf
22

3-
test/cli/fixtures/reporters/indicator-position.test.js eol=crlf
3+
test/e2e/fixtures/reporters/indicator-position.test.js eol=crlf

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ bench/test/*/*/
2323
docs/public/user-avatars
2424
.eslintcache
2525
docs/.vitepress/cache/
26-
!test/cli/fixtures/dotted-files/**/.cache
26+
!test/e2e/fixtures/dotted-files/**/.cache
2727
test/**/__screenshots__/**/*
2828
test/**/__traces__/**/*
2929
test/browser/fixtures/update-snapshot/basic.test.ts
30-
test/cli/fixtures/browser-multiple/basic-*
30+
test/e2e/fixtures/browser-multiple/basic-*
3131
.vitest-reports
3232
*.tsbuildinfo
3333
# exclude static html reporter folder
3434
test/browser/html/
35-
test/core/html/
35+
test/unit/html/
3636
.vitest
3737
explainFiles.txt
3838
.vitest-dump

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"label": "npm: test",
5959
"isBackground": true,
6060
"dependsOn": ["npm: dev"],
61-
"detail": "vitest -r test/core --api",
61+
"detail": "vitest -r test/unit --api",
6262
"problemMatcher": {
6363
"owner": "typescript",
6464
"fileLocation": "relative",

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Vitest is a next-generation testing framework powered by Vite. This is a monorep
3232
- **All tests**: `CI=true pnpm test:ci`
3333
- **Examples**: `CI=true pnpm test:examples`
3434
- **Specific test suite**: `CI=true cd test/<test-folder> && pnpm test <test-file>`
35-
- **Core directory test**: `CI=true pnpm test <test-file>` (for `test/core`)
35+
- **Unit directory test**: `CI=true pnpm test <test-file>` (for `test/unit`)
3636
- **Browser tests**: `CI=true pnpm test:browser:playwright` or `CI=true pnpm test:browser:webdriverio`
3737

3838
**IMPORTANT: Do NOT use `--` when passing test filters to pnpm.**
@@ -70,7 +70,7 @@ If you need to typecheck tests, run `pnpm typecheck` from the root of the worksp
7070
- `mocker` - Module mocking
7171

7272
### Test Organization (`test/`)
73-
- `test/core` - Core functionality tests
73+
- `test/unit` - Core functionality tests
7474
- `test/browser` - Browser-specific tests
7575
- Various test suites organized by feature
7676

_typos.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
extend-exclude = [
33
"*.js.map",
44
"*.svg",
5-
"test/cli/test/fixtures/reporters/html/**",
5+
"test/e2e/test/fixtures/reporters/html/**",
66
]
77

88
[default.extend-words]

eslint.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ export default antfu(
1414
'**/assets/**',
1515
'**/*.d.ts',
1616
'**/*.timestamp-*',
17-
'test/core/src/self',
18-
'test/core/test/mocking/already-hoisted.test.ts',
17+
'test/unit/src/self',
18+
'test/unit/test/mocking/already-hoisted.test.ts',
1919
'test/cache/cache/.vitest-base/results.json',
20-
'test/core/src/wasm/wasm-bindgen-no-cyclic',
20+
'test/unit/src/wasm/wasm-bindgen-no-cyclic',
2121
'test/workspaces/results.json',
2222
'test/workspaces-browser/results.json',
2323
'test/reporters/fixtures/with-syntax-error.test.js',
2424
'test/network-imports/public/slash@3.0.0.js',
2525
'test/coverage-test/src/transpiled.js',
2626
'test/coverage-test/src/original.ts',
27-
'test/cli/deps/error/*',
27+
'test/e2e/deps/error/*',
2828
'examples/**/mockServiceWorker.js',
2929
'examples/sveltekit/.svelte-kit',
3030
'packages/browser/**/esm-client-injector.js',
@@ -127,7 +127,7 @@ export default antfu(
127127
files: [
128128
`docs/${GLOB_SRC}`,
129129
`packages/web-worker/${GLOB_SRC}`,
130-
`test/core/${GLOB_SRC}`,
130+
`test/unit/${GLOB_SRC}`,
131131
],
132132
rules: {
133133
'no-restricted-globals': 'off',

packages/runner/src/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function withTimeout<T extends (...args: any[]) => any>(
5050

5151
const { setTimeout, clearTimeout } = getSafeTimers()
5252

53-
// this function name is used to filter error in test/cli/test/fails.test.ts
53+
// this function name is used to filter error in test/e2e/test/fails.test.ts
5454
return (function runWithTimeout(...args: T extends (...args: infer A) => any ? A : never) {
5555
const startTime = now()
5656
const runner = getRunner()

packages/ui/explorer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The new Explorer is using a flat structure to represent the tree via virtual scr
7272
It is using a new approach to handle the tree list, now we have a separated vue shallow ref for entries in the ui ([uiEntries in composables/explorer/state.ts](client/composables/explorer/state.ts)), and the WebSocket state using vue shallow ref for both, `idsMap` and `filesMap`, while keeping the state itself with Vue reactive.
7373
Now we are able to update the tree list only when the entries are updated and not when the WebSocket state is updated, which is a huge performance improvement.
7474

75-
Some numbers running `test/core` with Vitest UI (162 files with 3 workspaces: 5100+ tests) in a `i7-12700H` laptop:
75+
Some numbers running `test/unit` with Vitest UI (162 files with 3 workspaces: 5100+ tests) in a `i7-12700H` laptop:
7676
- tree list: after server finishing running the tests, Vitest UI took ~1 minute to finish rendering the full tree (~150MB of memory usage)
7777
- explorer: Vitest UI finishing rendering the full tree before the server reporter shows the tests summary (~10MB of memory usage)
7878

0 commit comments

Comments
 (0)