Skip to content

Commit

Permalink
feat(experimental): expose vite on the test project as a separate field
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Oct 29, 2024
1 parent 47d7c0a commit bcc5908
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/advanced/reporters.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ declare class TestProject {
* @experimental The public Vitest API is experimental and does not follow semver.
*/
readonly workspaceProject: WorkspaceProject
/**
* Vite's dev server instance. Every workspace project has its own server.
*/
readonly vite: ViteDevServer
/**
* Resolved project configuration.
*/
Expand Down
6 changes: 6 additions & 0 deletions packages/vitest/src/node/reported-workspace-project.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ViteDevServer } from 'vite'
import type { ProvidedContext } from '../types/general'
import type { Vitest } from './core'
import type { ResolvedConfig, ResolvedProjectConfig, SerializedConfig } from './types/config'
Expand All @@ -15,6 +16,10 @@ export class TestProject {
*/
public readonly workspaceProject: WorkspaceProject

/**
* Vite's dev server instance. Every workspace project has its own server.
*/
public readonly vite: ViteDevServer
/**
* Resolved project configuration.
*/
Expand All @@ -32,6 +37,7 @@ export class TestProject {
constructor(workspaceProject: WorkspaceProject) {
this.workspaceProject = workspaceProject
this.vitest = workspaceProject.ctx
this.vite = workspaceProject.server
this.globalConfig = workspaceProject.ctx.config
this.config = workspaceProject.config
this.name = workspaceProject.getName()
Expand Down

0 comments on commit bcc5908

Please sign in to comment.