Skip to content

Commit bcc5908

Browse files
committedOct 29, 2024··
feat(experimental): expose vite on the test project as a separate field
1 parent 47d7c0a commit bcc5908

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
 

‎docs/advanced/reporters.md

+4
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@ declare class TestProject {
402402
* @experimental The public Vitest API is experimental and does not follow semver.
403403
*/
404404
readonly workspaceProject: WorkspaceProject
405+
/**
406+
* Vite's dev server instance. Every workspace project has its own server.
407+
*/
408+
readonly vite: ViteDevServer
405409
/**
406410
* Resolved project configuration.
407411
*/

‎packages/vitest/src/node/reported-workspace-project.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ViteDevServer } from 'vite'
12
import type { ProvidedContext } from '../types/general'
23
import type { Vitest } from './core'
34
import type { ResolvedConfig, ResolvedProjectConfig, SerializedConfig } from './types/config'
@@ -15,6 +16,10 @@ export class TestProject {
1516
*/
1617
public readonly workspaceProject: WorkspaceProject
1718

19+
/**
20+
* Vite's dev server instance. Every workspace project has its own server.
21+
*/
22+
public readonly vite: ViteDevServer
1823
/**
1924
* Resolved project configuration.
2025
*/
@@ -32,6 +37,7 @@ export class TestProject {
3237
constructor(workspaceProject: WorkspaceProject) {
3338
this.workspaceProject = workspaceProject
3439
this.vitest = workspaceProject.ctx
40+
this.vite = workspaceProject.server
3541
this.globalConfig = workspaceProject.ctx.config
3642
this.config = workspaceProject.config
3743
this.name = workspaceProject.getName()

0 commit comments

Comments
 (0)
Please sign in to comment.