vitest-dev / vitest

Next generation testing framework powered by Vite.
https://vitest.dev
MIT License
13.13k stars 1.18k forks source link

refactor: merge `TestProject` with `WorkspaceProject` #6906

Closed sheremet-va closed 4 days ago

sheremet-va commented 1 week ago

Description

In preparation for the public API. Previously TestProject was a prototype for the public API, but it was hard to work with internally because it was too restrictive. In this PR I decided to merge them together and introduce a sort of convention:

The public test project API now looks like this (excluding deprecated and private APIs):

export interface TestProject {
  readonly name: string
  readonly serializedConfig: SerializedConfig
  readonly globalConfig: ResolvedConfig
  readonly vitest: Vitest
  readonly config: ResolvedConfig // project config
  readonly vite: ViteDevServer
  browser?: BrowserServer

  provide(key: string | symbol, value: unknown): void
  getProvidedContext(): ProvidedContext
  createSpecification(moduleId: string, pool?: string): TestSpecification
  isRootProject(): boolean
  globTestFiles(filters?: string[]): Promise<{ testFiles, typecheckTestFiles }>
  matchesTestGlob(filepath: string, code?: string): boolean
  close(): Promise<void>
}

image

TODO:

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

Tests

Documentation

Changesets

netlify[bot] commented 1 week ago

Deploy Preview for vitest-dev ready!

Name Link
Latest commit ce19da046d7b44c3931600700c383f47f28d7e75
Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/673b07da0e59d20008a89d4d
Deploy Preview https://deploy-preview-6906--vitest-dev.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.