feat!: inline @vitest/runner package, do not publish it anymore (#1… · vitest-dev/vitest@6d6e46b (original) (raw)
File tree
- artifacts/visual-regression
- exact-optional-property-no-node
* exact-optional-property-node
- exact-optional-property-no-node
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -95,7 +95,7 @@ export interface VitestRunner { | ||
| 95 | 95 | /** |
| 96 | 96 | * Publicly available configuration. |
| 97 | 97 | */ |
| 98 | - config: VitestRunnerConfig | |
| 98 | + config: SerializedConfig | |
| 99 | 99 | /** |
| 100 | 100 | * The name of the current pool. Can affect how stack trace is inferred on the server side. |
| 101 | 101 | */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -27,7 +27,7 @@ This is a global [`ViteDevServer`](https://vite.dev/guide/api-javascript#vitedev | ||
| 27 | 27 | Public `state` is an experimental API (except `vitest.state.getReportedEntity`). Breaking changes might not follow SemVer, please pin Vitest's version when using it. |
| 28 | 28 | ::: |
| 29 | 29 | |
| 30 | -Global state stores information about the current tests. It uses the same API from `@vitest/runner` by default, but we recommend using the [Reported Tasks API](/api/advanced/reporters#reported-tasks) instead by calling `state.getReportedEntity()` on the `@vitest/runner` API: | |
| 30 | +Global state stores information about the current tests. It uses internal serializable Task API by default, but we recommend using the [Reported Tasks API](/api/advanced/reporters#reported-tasks) instead by calling `state.getReportedEntity()`: | |
| 31 | 31 | |
| 32 | 32 | ```ts |
| 33 | 33 | const task = vitest.state.idMap.get(taskId) // old API |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -92,7 +92,6 @@ | ||
| 92 | 92 | "@types/node": "catalog:", |
| 93 | 93 | "@types/pngjs": "^6.0.5", |
| 94 | 94 | "@types/ws": "catalog:", |
| 95 | -"@vitest/runner": "workspace:*", | |
| 96 | 95 | "birpc": "catalog:", |
| 97 | 96 | "flatted": "catalog:", |
| 98 | 97 | "ivya": "^1.8.2", |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| 1 | -import type { CancelReason, FileSpecification } from '@vitest/runner' | |
| 1 | +import type { CancelReason } from 'vitest' | |
| 2 | +import type { FileSpecification } from 'vitest/internal/browser' | |
| 2 | 3 | import type { OTELCarrier } from 'vitest/internal/traces' |
| 3 | 4 | import { getBrowserState } from './utils' |
| 4 | 5 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | import type { ModuleMocker } from '@vitest/mocker/browser' |
| 2 | -import type { CancelReason } from '@vitest/runner' | |
| 3 | 2 | import type { BirpcReturn } from 'birpc' |
| 3 | +import type { CancelReason } from 'vitest' | |
| 4 | 4 | import type { MarkOptions } from 'vitest/browser' |
| 5 | 5 | import type { WebSocketBrowserEvents, WebSocketBrowserHandlers } from '../types' |
| 6 | 6 | import type { IframeOrchestrator } from './orchestrator' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,12 @@ | ||
| 1 | 1 | import type { Context as OTELContext } from '@opentelemetry/api' |
| 2 | 2 | import type { GlobalChannelIncomingEvent, IframeChannelIncomingEvent, IframeChannelOutgoingEvent, IframeViewportDoneEvent, IframeViewportFailEvent } from '@vitest/browser/client' |
| 3 | -import type { FileSpecification } from '@vitest/runner' | |
| 4 | 3 | import type { BrowserTesterOptions, SerializedConfig } from 'vitest' |
| 4 | +import type { FileSpecification } from 'vitest/internal/browser' | |
| 5 | 5 | import { channel, client, globalChannel } from '@vitest/browser/client' |
| 6 | 6 | import { relative } from 'pathe' |
| 7 | 7 | import { Traces } from 'vitest/internal/traces' |
| 8 | +// This needs to be tree shaken properly to not include the whole runner by accident | |
| 9 | +import { generateFileHash } from '../../../vitest/src/utils/tasks.js' | |
| 8 | 10 | import { getUiAPI } from './ui' |
| 9 | 11 | import { getBrowserState, getConfig } from './utils' |
| 10 | 12 | |
| @@ -481,39 +483,6 @@ function generateFileId(file: string) { | ||
| 481 | 483 | ) |
| 482 | 484 | } |
| 483 | 485 | |
| 484 | -// TODO: copied from packages/runner/src/utils/collect.ts | |
| 485 | -interface HashMeta { | |
| 486 | -typecheck?: boolean | |
| 487 | -__vitest_label__?: string | |
| 488 | -} | |
| 489 | - | |
| 490 | -function generateFileHash( | |
| 491 | -file: string, | |
| 492 | -projectName: string | undefined, | |
| 493 | -meta?: HashMeta, | |
| 494 | -): string { | |
| 495 | -const seed = [ | |
| 496 | -file, | |
| 497 | -projectName | | |
| 498 | -meta?.typecheck ? '__typecheck__' : '', | |
| 499 | -meta?.__vitest_label__ | | |
| 500 | -].join('\0') | |
| 501 | -return generateHash(seed) | |
| 502 | -} | |
| 503 | - | |
| 504 | -function generateHash(str: string): string { | |
| 505 | -let hash = 0 | |
| 506 | -if (str.length === 0) { | |
| 507 | -return `${hash}` | |
| 508 | -} | |
| 509 | -for (let i = 0; i < str.length; i++) { | |
| 510 | -const char = str.charCodeAt(i) | |
| 511 | -hash = (hash << 5) - hash + char | |
| 512 | -hash = hash & hash // Convert to 32bit integer | |
| 513 | -} | |
| 514 | -return `${hash}` | |
| 515 | -} | |
| 516 | - | |
| 517 | 486 | async function setIframeViewport( |
| 518 | 487 | width: number, |
| 519 | 488 | height: number, |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| 1 | -import type { VisualRegressionArtifact } from '@vitest/runner' | |
| 2 | -import type { AsyncMatcherResult, MatcherState } from 'vitest' | |
| 1 | +import type { AsyncMatcherResult, MatcherState, VisualRegressionArtifact } from 'vitest' | |
| 3 | 2 | import type { BrowserPage, ScreenshotMatcherOptions } from '../../../../context' |
| 4 | 3 | import type { ScreenshotMatcherArguments, ScreenshotMatcherOutput } from '../../../shared/screenshotMatcher/types' |
| 5 | 4 | import type { Locator } from '../locators' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,22 @@ | ||
| 1 | 1 | import type { |
| 2 | 2 | CancelReason, |
| 3 | -File, | |
| 4 | -Suite, | |
| 5 | -Task, | |
| 6 | -TaskEventPack, | |
| 7 | -TaskResultPack, | |
| 8 | -Test, | |
| 3 | +RunnerTestFile as File, | |
| 4 | +SerializedConfig, | |
| 5 | +RunnerTestSuite as Suite, | |
| 6 | +RunnerTask as Task, | |
| 7 | +RunnerTaskEventPack as TaskEventPack, | |
| 8 | +RunnerTaskResultPack as TaskResultPack, | |
| 9 | +RunnerTestCase as Test, | |
| 9 | 10 | TestAnnotation, |
| 10 | 11 | TestArtifact, |
| 12 | +TestExecutionMethod, | |
| 11 | 13 | TestTryOptions, |
| 12 | -VitestRunner, | |
| 13 | -} from '@vitest/runner' | |
| 14 | -import type { SerializedConfig, TestExecutionMethod, WorkerGlobalState } from 'vitest' | |
| 14 | +VitestTestRunner as VitestRunner, | |
| 15 | + WorkerGlobalState, | |
| 16 | +} from 'vitest' | |
| 15 | 17 | import type { VitestBrowserClientMocker } from './mocker' |
| 16 | 18 | import type { CommandsManager } from './tester-utils' |
| 17 | 19 | import { globalChannel, onCancel } from '@vitest/browser/client' |
| 18 | -import { getTestName } from '@vitest/runner/utils' | |
| 19 | 20 | import { recordArtifact, TestRunner } from 'vitest' |
| 20 | 21 | import { page, userEvent } from 'vitest/browser' |
| 21 | 22 | import { |
| @@ -26,6 +27,7 @@ import { | ||
| 26 | 27 | takeCoverageInsideWorker, |
| 27 | 28 | } from 'vitest/internal/browser' |
| 28 | 29 | import { createStackString, parseStacktrace } from '../../../../utils/src/source-map' |
| 30 | +import { getTestName } from '../../../../vitest/src/utils/tasks' | |
| 29 | 31 | import { getBrowserState, getWorkerState, moduleRunner, now } from '../utils' |
| 30 | 32 | import { rpc } from './rpc' |
| 31 | 33 | import { VitestBrowserSnapshotEnvironment } from './snapshot' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | import type { BrowserRPC, IframeChannelEvent } from '@vitest/browser/client' |
| 2 | -import type { FileSpecification } from '@vitest/runner' | |
| 2 | +import type { FileSpecification } from 'vitest/internal/browser' | |
| 3 | 3 | import { channel, client, onCancel, registerPageMarkHandler } from '@vitest/browser/client' |
| 4 | 4 | import { parse } from 'flatted' |
| 5 | 5 | import { page, server, userEvent } from 'vitest/browser' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| 1 | -import type { Task } from '@vitest/runner' | |
| 1 | +import type { RunnerTask as Task } from 'vitest' | |
| 2 | 2 | import type { BrowserTraceEntryKind } from 'vitest/browser' |
| 3 | 3 | import type { BrowserRPC } from '../client' |
| 4 | 4 | import type { SerializedLocator } from './locators' |