Skip to content

Commit df6d750

Browse files
authored
fix(vitest): don't fail if the working directory starts with a lowercase drive letter (#6779)
1 parent 169028f commit df6d750

File tree

20 files changed

+64
-24
lines changed

20 files changed

+64
-24
lines changed

packages/browser/src/client/public/error-catcher.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ async function reportUnexpectedError(
5656
error,
5757
) {
5858
const processedError = serializeError(error)
59-
await client.rpc.onUnhandledError(processedError, type)
59+
await client.waitForConnection().then(() => {
60+
return client.rpc.onUnhandledError(processedError, type)
61+
}).catch(console.error)
6062
const state = __vitest_browser_runner__
6163

6264
if (state.type === 'orchestrator') {

packages/browser/src/node/serverTester.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export async function resolveTester(
6060
try {
6161
const indexhtml = await server.vite.transformIndexHtml(url.pathname, testerHtml)
6262
return replacer(indexhtml, {
63+
__VITEST_FAVICON__: server.faviconUrl,
6364
__VITEST_INJECTOR__: injector,
6465
__VITEST_APPEND__: `
6566
__vitest_browser_runner__.runningFiles = ${tests}

packages/ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"codemirror-theme-vars": "^0.1.2",
7777
"d3-graph-controller": "^3.0.11",
7878
"floating-vue": "^5.2.2",
79+
"rollup": "^4.24.0",
7980
"splitpanes": "^3.1.5",
8081
"unocss": "^0.63.6",
8182
"unplugin-auto-import": "^0.18.3",

packages/vite-node/src/client.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import type { HotContext, ModuleCache, ViteNodeRunnerOptions } from './types'
22

33
import { createRequire } from 'node:module'
4-
// we need native dirname, because windows __dirname has \\
5-
import { dirname } from 'node:path'
4+
import { dirname, resolve } from 'node:path'
65
import { fileURLToPath, pathToFileURL } from 'node:url'
76
import vm from 'node:vm'
87
import createDebug from 'debug'
9-
import { resolve } from 'pathe'
108
import { extractSourceMap } from './source-map'
119
import {
1210
cleanUrl,

packages/vite-node/src/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export function normalizeRequestId(id: string, base?: string): string {
2828
id = `/${id.slice(base.length)}`
2929
}
3030

31-
// keep drive the same as in process cwd
31+
// keep drive the same as in process cwd. ideally, this should be resolved on Vite side
32+
// Vite always resolves drive letters to the upper case because of the use of `realpathSync`
33+
// https://github.com/vitejs/vite/blob/0ab20a3ee26eacf302415b3087732497d0a2f358/packages/vite/src/node/utils.ts#L635
3234
if (driveRegexp && !driveRegexp?.test(id) && driveOppositeRegext?.test(id)) {
3335
id = id.replace(driveOppositeRegext, `${drive}$1`)
3436
}

packages/vitest/src/node/plugins/mocks.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import type { Plugin } from 'vite'
22
import { automockPlugin, hoistMocksPlugin } from '@vitest/mocker/node'
3+
import { normalize } from 'pathe'
34
import { distDir } from '../../paths'
45
import { generateCodeFrame } from '../error'
56

67
export function MocksPlugins(): Plugin[] {
8+
const normalizedDistDir = normalize(distDir)
79
return [
810
hoistMocksPlugin({
911
filter(id) {
10-
if (id.includes(distDir)) {
12+
if (id.includes(normalizedDistDir)) {
1113
return false
1214
}
1315
return true

packages/vitest/src/node/pools/forks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import type { SerializedConfig } from '../types/config'
77
import type { WorkspaceProject } from '../workspace'
88
import EventEmitter from 'node:events'
99
import * as nodeos from 'node:os'
10+
import { resolve } from 'node:path'
1011
import v8 from 'node:v8'
1112
import { createBirpc } from 'birpc'
12-
import { resolve } from 'pathe'
1313
import { Tinypool } from 'tinypool'
1414
import { groupBy } from '../../utils/base'
1515
import { wrapSerializableConfig } from '../../utils/config-helpers'

packages/vitest/src/node/pools/threads.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import type { SerializedConfig } from '../types/config'
77
import type { WorkerContext } from '../types/worker'
88
import type { WorkspaceProject } from '../workspace'
99
import * as nodeos from 'node:os'
10+
import { resolve } from 'node:path'
1011
import { MessageChannel } from 'node:worker_threads'
1112
import { createBirpc } from 'birpc'
12-
import { resolve } from 'pathe'
1313
import Tinypool from 'tinypool'
1414
import { groupBy } from '../../utils/base'
1515
import { envsOrder, groupFilesByEnv } from '../../utils/test-helpers'

packages/vitest/src/node/pools/vmForks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import type { ResolvedConfig, SerializedConfig } from '../types/config'
77
import type { WorkspaceProject } from '../workspace'
88
import EventEmitter from 'node:events'
99
import * as nodeos from 'node:os'
10+
import { resolve } from 'node:path'
1011
import v8 from 'node:v8'
1112
import { createBirpc } from 'birpc'
12-
import { resolve } from 'pathe'
1313
import Tinypool from 'tinypool'
1414
import { rootDir } from '../../paths'
1515
import { wrapSerializableConfig } from '../../utils/config-helpers'

packages/vitest/src/node/pools/vmThreads.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import type { ResolvedConfig, SerializedConfig } from '../types/config'
77
import type { WorkerContext } from '../types/worker'
88
import type { WorkspaceProject } from '../workspace'
99
import * as nodeos from 'node:os'
10+
import { resolve } from 'node:path'
1011
import { MessageChannel } from 'node:worker_threads'
1112
import { createBirpc } from 'birpc'
12-
import { resolve } from 'pathe'
1313
import Tinypool from 'tinypool'
1414
import { rootDir } from '../../paths'
1515
import { getWorkerMemoryLimit, stringToBytes } from '../../utils/memory-limit'

0 commit comments

Comments
 (0)