Skip to content

Commit 1e60c4f

Browse files
authored
fix!: remove Node types from the main entry point, use vitest/node instead (#8200)
1 parent 5261df0 commit 1e60c4f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+273
-302
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ test/cli/fixtures/browser-multiple/basic-*
3232
# exclude static html reporter folder
3333
test/browser/html/
3434
test/core/html/
35-
.vitest-attachments
35+
.vitest-attachments
36+
explainFiles.txt

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"test:ci": "CI=true pnpm -r --reporter-hide-prefix --stream --sequential --filter '@vitest/test-*' --filter !test-browser run test",
2828
"test:examples": "CI=true pnpm -r --reporter-hide-prefix --stream --filter '@vitest/example-*' run test",
2929
"test:ecosystem-ci": "ECOSYSTEM_CI=true pnpm test:ci",
30+
"typebuild": "tsx ./scripts/explain-types.ts",
3031
"typecheck": "tsc -p tsconfig.check.json --noEmit",
3132
"typecheck:why": "tsc -p tsconfig.check.json --noEmit --explainFiles > explainTypes.txt",
3233
"ui:build": "vite build packages/ui",

packages/browser/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
"providers"
6565
],
6666
"scripts": {
67+
"typecheck": "tsc -p ./src/client/tsconfig.json --noEmit",
68+
"typecheck:why": "tsc -p ./src/client/tsconfig.json --noEmit --explainFiles > explainTypes.txt",
6769
"build": "rimraf dist && pnpm build:node && pnpm build:client",
6870
"build:client": "vite build src/client",
6971
"build:node": "rollup -c",

packages/browser/src/client/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ModuleMocker } from '@vitest/mocker/browser'
22
import type { CancelReason } from '@vitest/runner'
33
import type { BirpcReturn } from 'birpc'
4-
import type { WebSocketBrowserEvents, WebSocketBrowserHandlers } from '../node/types'
4+
import type { WebSocketBrowserEvents, WebSocketBrowserHandlers } from '../types'
55
import type { IframeOrchestrator } from './orchestrator'
66
import { createBirpc } from 'birpc'
77
import { parse, stringify } from 'flatted'

packages/browser/src/client/tester/context.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import type { Options as TestingLibraryOptions, UserEvent as TestingLibraryUserEvent } from '@testing-library/user-event'
2-
import type { RunnerTask } from 'vitest'
1+
import type {
2+
Options as TestingLibraryOptions,
3+
UserEvent as TestingLibraryUserEvent,
4+
} from '@testing-library/user-event'
35
import type {
46
BrowserLocators,
57
BrowserPage,
68
Locator,
79
UserEvent,
8-
} from '../../../context'
10+
} from '@vitest/browser/context'
11+
import type { RunnerTask } from 'vitest'
912
import type { IframeViewportEvent } from '../client'
1013
import type { BrowserRunnerState } from '../utils'
1114
import type { Locator as LocatorAPI } from './locators/index'
@@ -289,12 +292,19 @@ export const page: BrowserPage = {
289292
const name
290293
= options.path || `${taskName.replace(/[^a-z0-9]/gi, '-')}-${number}.png`
291294

292-
return ensureAwaited(error => triggerCommand('__vitest_screenshot', [name, processTimeoutOptions({
293-
...options,
294-
element: options.element
295-
? convertToSelector(options.element)
296-
: undefined,
297-
})], error))
295+
return ensureAwaited(error => triggerCommand(
296+
'__vitest_screenshot',
297+
[
298+
name,
299+
processTimeoutOptions({
300+
...options,
301+
element: options.element
302+
? convertToSelector(options.element)
303+
: undefined,
304+
} as any /** TODO */),
305+
],
306+
error,
307+
))
298308
},
299309
getByRole() {
300310
throw new Error(`Method "getByRole" is not implemented in the "${provider}" provider.`)

packages/browser/src/client/tester/locators/playwright.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import type { UserEventClearOptions, UserEventClickOptions, UserEventDragAndDropOptions, UserEventFillOptions, UserEventHoverOptions, UserEventSelectOptions, UserEventUploadOptions } from '@vitest/browser/context'
1+
import type {
2+
UserEventClearOptions,
3+
UserEventClickOptions,
4+
UserEventDragAndDropOptions,
5+
UserEventFillOptions,
6+
UserEventHoverOptions,
7+
UserEventSelectOptions,
8+
UserEventUploadOptions,
9+
} from '@vitest/browser/context'
210
import { page, server } from '@vitest/browser/context'
311
import {
412
getByAltTextSelector,

packages/browser/src/client/tester/locators/webdriverio.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import type { UserEventClickOptions, UserEventDragAndDropOptions, UserEventHoverOptions, UserEventSelectOptions } from '@vitest/browser/context'
1+
import type {
2+
UserEventClickOptions,
3+
UserEventDragAndDropOptions,
4+
UserEventHoverOptions,
5+
UserEventSelectOptions,
6+
} from '@vitest/browser/context'
27
import { page, server } from '@vitest/browser/context'
38
import {
49
getByAltTextSelector,

packages/browser/src/client/tester/runner.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { CancelReason, File, Suite, Task, TaskEventPack, TaskResultPack, Test, TestAnnotation, VitestRunner } from '@vitest/runner'
22
import type { SerializedConfig, TestExecutionMethod, WorkerGlobalState } from 'vitest'
3-
import type { VitestExecutor } from 'vitest/execute'
43
import type { VitestBrowserClientMocker } from './mocker'
54
import { globalChannel, onCancel } from '@vitest/browser/client'
65
import { page, userEvent } from '@vitest/browser/context'
@@ -77,7 +76,7 @@ export function createBrowserRunner(
7776
if (this.config.browser.screenshotFailures && document.body.clientHeight > 0 && task.result?.state === 'fail') {
7877
const screenshot = await page.screenshot({
7978
timeout: this.config.browser.providerOptions?.actionTimeout ?? 5_000,
80-
}).catch((err) => {
79+
} as any /** TODO */).catch((err) => {
8180
console.error('[vitest] Failed to take a screenshot', err)
8281
})
8382
if (screenshot) {
@@ -239,8 +238,8 @@ export async function initiateRunner(
239238
})
240239

241240
const [diffOptions] = await Promise.all([
242-
loadDiffConfig(config, executor as unknown as VitestExecutor),
243-
loadSnapshotSerializers(config, executor as unknown as VitestExecutor),
241+
loadDiffConfig(config, executor as any),
242+
loadSnapshotSerializers(config, executor as any),
244243
])
245244
runner.config.diffOptions = diffOptions
246245
getWorkerState().onFilterStackTrace = (stack: string) => {

packages/browser/src/client/tester/state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const state: WorkerGlobalState = {
3232
},
3333
onCleanup: fn => getBrowserState().cleanups.push(fn),
3434
moduleCache: getBrowserState().moduleCache,
35+
moduleExecutionInfo: new Map(),
3536
rpc: null as any,
3637
durations: {
3738
environment: 0,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"extends": "../../../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"lib": [
5+
"dom",
6+
"esnext",
7+
"DOM.Iterable"
8+
],
9+
"types": ["vite/client"],
10+
"noEmit": true
11+
},
12+
"include": [
13+
"./**/*.ts",
14+
"../types.ts",
15+
"../../matchers.d.ts",
16+
"../../../vitest/src/integrations/chai/chai-subset.d.ts"
17+
],
18+
"exclude": [
19+
"./vite.config.ts"
20+
]
21+
}

0 commit comments

Comments
 (0)