Skip to content

Commit 4b41576

Browse files
committed
deps(cli): use vitest v4
1 parent 508d21b commit 4b41576

8 files changed

Lines changed: 137 additions & 276 deletions

File tree

packages/cli/snap-tests/command-helper/snap.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,20 +239,19 @@ Options:
239239
--api [port] Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on. If true will be set to 51204. Use '--help --api' for more info.
240240
--silent [value] Silent console output from tests. Use 'passed-only' to see logs from failing tests only.
241241
--hideSkippedTests Hide logs for skipped tests
242-
--reporter <name> Specify reporters (default, basic, blob, verbose, dot, json, tap, tap-flat, junit, hanging-process, github-actions)
242+
--reporter <name> Specify reporters (default, blob, verbose, dot, json, tap, tap-flat, junit, tree, hanging-process, github-actions)
243243
--outputFile <filename/-s> Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters (example: --outputFile.tap=./tap.txt)
244244
--coverage Enable coverage report. Use '--help --coverage' for more info.
245245
--mode <name> Override Vite mode (default: test or benchmark)
246-
--workspace <path> [deprecated] Path to a workspace configuration file
247246
--isolate Run every test file in isolation. To disable isolation, use --no-isolate (default: true)
248247
--globals Inject apis globally
249248
--dom Mock browser API with happy-dom
250249
--browser <name> Run tests in the browser. Equivalent to --browser.enabled (default: false). Use '--help --browser' for more info.
251250
--pool <pool> Specify pool, if not running in the browser (default: forks)
252-
--poolOptions <options> Specify pool options. Use '--help --poolOptions' for more info.
251+
--execArgv <option> Pass additional arguments to node process when spawning worker_threads or child_process.
252+
--vmMemoryLimit <limit> Memory limit for VM pools. If you see memory leaks, try to tinker this value.
253253
--fileParallelism Should all test files run in parallel. Use --no-file-parallelism to disable (default: true)
254254
--maxWorkers <workers> Maximum number or percentage of workers to run tests in
255-
--minWorkers <workers> Minimum number or percentage of workers to run tests in
256255
--environment <name> Specify runner environment, if not running in the browser (default: node)
257256
--passWithNoTests Pass when no tests are found
258257
--logHeapUsage Show the size of heap for each test when running in node
@@ -285,7 +284,7 @@ Options:
285284
--no-color Removes colors from the console output (default: true)
286285
--clearScreen Clear terminal screen when re-running tests during watch mode (default: true)
287286
--configLoader <loader> Use bundle to bundle the config with esbuild or runner (experimental) to process it on the fly. This is only available in vite version <semver> and above. (default: bundle)
288-
--standalone Start Vitest without running tests. File filters will be ignored, tests will be running only on change (default: false)
287+
--standalone Start Vitest without running tests. Tests will be running only on change. This option is ignored when CLI file filters are passed. (default: false)
289288
--mergeReports [path] Path to a blob reports directory. If this options is used, Vitest won't run any tests, it will only report previously recorded tests
290289
-h, --help Display this message
291290

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
{
2+
"name": "vitest-browser-mode",
3+
"version": "1.0.0",
4+
"packageManager": "pnpm@10.19.0",
5+
"dependencies": {
6+
"@vitest/browser-playwright": "^4.0.1"
7+
}
28
}

packages/cli/snap-tests/vitest-browser-mode/snap.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
> vite install
2+
Packages: +<variable>
3+
+<repeat>
4+
Progress: resolved <variable>, reused <variable>, downloaded <variable>, added <variable>, done
5+
6+
dependencies:
7+
+ @vitest/browser-playwright <semver>
8+
9+
╭ Warning ─────────────────────────────────────────────────────────────────────╮
10+
│ │
11+
│ Ignored build scripts: esbuild. │
12+
│ Run "pnpm approve-builds" to pick which dependencies should be allowed │
13+
│ to run scripts. │
14+
│ │
15+
╰──────────────────────────────────────────────────────────────────────────────╯
16+
17+
Done in <variable>ms using pnpm v<semver>
18+
19+
120
> vite test
221

322
RUN v<semver> <cwd>

packages/cli/snap-tests/vitest-browser-mode/steps.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"VITE_DISABLE_AUTO_INSTALL": "1"
44
},
55
"commands": [
6+
"vite install",
67
"vite test",
78
"echo //comment >> src/foo.js",
89
"vite test",

packages/cli/snap-tests/vitest-browser-mode/vitest.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// import { defineProject } from 'vitest/config';
2+
import { playwright } from '@vitest/browser-playwright';
23

34
export default {
45
test: {
56
browser: {
67
enabled: true,
7-
provider: 'playwright',
8+
provider: playwright(),
89
headless: true,
910
instances: [
1011
{

packages/cli/src/resolve-test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Used for: `vite-plus test` command
99
*/
1010

11+
import { dirname, join } from 'node:path';
1112
import { DEFAULT_ENVS, resolve } from './utils.js';
1213

1314
/**
@@ -24,8 +25,10 @@ export async function test(): Promise<{
2425
binPath: string;
2526
envs: Record<string, string>;
2627
}> {
27-
// Resolve the Vitest CLI module directly
28-
const binPath = resolve('vitest/vitest.mjs');
28+
// try to resolve vitest package.json
29+
const pkgJsonPath = resolve('vitest/package.json');
30+
// vitest's CLI binary is located at vitest.mjs relative to the package root
31+
const binPath = join(dirname(pkgJsonPath), 'vitest.mjs');
2932

3033
return {
3134
binPath,

0 commit comments

Comments
 (0)