Skip to content
Merged
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
9 changes: 4 additions & 5 deletions packages/cli/snap-tests/command-helper/snap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,20 +239,19 @@ Options:
--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.
--silent [value] Silent console output from tests. Use 'passed-only' to see logs from failing tests only.
--hideSkippedTests Hide logs for skipped tests
--reporter <name> Specify reporters (default, basic, blob, verbose, dot, json, tap, tap-flat, junit, hanging-process, github-actions)
--reporter <name> Specify reporters (default, blob, verbose, dot, json, tap, tap-flat, junit, tree, hanging-process, github-actions)
--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)
--coverage Enable coverage report. Use '--help --coverage' for more info.
--mode <name> Override Vite mode (default: test or benchmark)
--workspace <path> [deprecated] Path to a workspace configuration file
--isolate Run every test file in isolation. To disable isolation, use --no-isolate (default: true)
--globals Inject apis globally
--dom Mock browser API with happy-dom
--browser <name> Run tests in the browser. Equivalent to --browser.enabled (default: false). Use '--help --browser' for more info.
--pool <pool> Specify pool, if not running in the browser (default: forks)
--poolOptions <options> Specify pool options. Use '--help --poolOptions' for more info.
--execArgv <option> Pass additional arguments to node process when spawning worker_threads or child_process.
--vmMemoryLimit <limit> Memory limit for VM pools. If you see memory leaks, try to tinker this value.
--fileParallelism Should all test files run in parallel. Use --no-file-parallelism to disable (default: true)
--maxWorkers <workers> Maximum number or percentage of workers to run tests in
--minWorkers <workers> Minimum number or percentage of workers to run tests in
--environment <name> Specify runner environment, if not running in the browser (default: node)
--passWithNoTests Pass when no tests are found
--logHeapUsage Show the size of heap for each test when running in node
Expand Down Expand Up @@ -285,7 +284,7 @@ Options:
--no-color Removes colors from the console output (default: true)
--clearScreen Clear terminal screen when re-running tests during watch mode (default: true)
--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)
--standalone Start Vitest without running tests. File filters will be ignored, tests will be running only on change (default: false)
--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)
--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
-h, --help Display this message

6 changes: 6 additions & 0 deletions packages/cli/snap-tests/command-lib/snap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ Options:
✔ Build complete in <variable>ms


⚠ Deprecation Warning: The top-level "define" option is deprecated. Use "transform.define" instead.
⚠ Deprecation Warning: The top-level "inject" option is deprecated. Use "transform.inject" instead.

> ls dist # should have the library
index.js

Expand All @@ -71,3 +74,6 @@ index.js
ℹ 1 files, total: <variable> kB
✔ Build complete in <variable>ms


⚠ Deprecation Warning: The top-level "define" option is deprecated. Use "transform.define" instead.
⚠ Deprecation Warning: The top-level "inject" option is deprecated. Use "transform.inject" instead.
6 changes: 6 additions & 0 deletions packages/cli/snap-tests/vitest-browser-mode/package.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
{
"name": "vitest-browser-mode",
"version": "1.0.0",
"packageManager": "pnpm@10.19.0",
"dependencies": {
"@vitest/browser-playwright": "^4.0.1"
}
}
19 changes: 19 additions & 0 deletions packages/cli/snap-tests/vitest-browser-mode/snap.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
> vite install
Packages: +<variable>
+<repeat>
Progress: resolved <variable>, reused <variable>, downloaded <variable>, added <variable>, done

dependencies:
+ @vitest/browser-playwright <semver>

╭ Warning ─────────────────────────────────────────────────────────────────────╮
│ │
│ Ignored build scripts: esbuild. │
│ Run "pnpm approve-builds" to pick which dependencies should be allowed │
│ to run scripts. │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯

Done in <variable>ms using pnpm v<semver>


> vite test

RUN v<semver> <cwd>
Expand Down
1 change: 1 addition & 0 deletions packages/cli/snap-tests/vitest-browser-mode/steps.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vite install",
"vite test",
"echo //comment >> src/foo.js",
"vite test",
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/snap-tests/vitest-browser-mode/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// import { defineProject } from 'vitest/config';
import { playwright } from '@vitest/browser-playwright';

export default {
test: {
browser: {
enabled: true,
provider: 'playwright',
provider: playwright(),
headless: true,
instances: [
{
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/resolve-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Used for: `vite-plus test` command
*/

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

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

return {
binPath,
Expand Down
Loading
Loading