Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: misc fix for vite 6 ecosystem ci #6867

Merged
merged 20 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/vitest/src/node/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ export async function VitestPlugin(
) {
const watch = config.server!.watch
if (watch) {
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore Vite 6 compat
watch.useFsEvents = false
watch.usePolling = false
}
Expand Down
2 changes: 2 additions & 0 deletions packages/vitest/src/typecheck/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export async function collectTests(
if (!request) {
return null
}
// unwrap __vite_ssr_identity__ for Vite 6
request.code = request.code.replace(/__vite_ssr_identity__\((\w+\.\w+)\)/g, '( $1)')
const ast = await parseAstAsync(request.code)
const testFilepath = relative(ctx.config.root, filepath)
const projectName = ctx.getName()
Expand Down
3 changes: 3 additions & 0 deletions test/cli/fixtures/vm-threads/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ export default defineConfig({
},
},
},
build: {
assetsInlineLimit: 0,
},
})
13 changes: 11 additions & 2 deletions test/cli/test/inspect.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { InspectorNotification } from 'node:inspector'
import { version as viteVersion } from 'vite'
import { expect, test } from 'vitest'
import WebSocket from 'ws'

Expand Down Expand Up @@ -35,8 +36,16 @@ test('--inspect-brk stops at test file', async () => {
send({ method: 'Debugger.getScriptSource', params: { scriptId } })
const { result } = await response as any

expect(result.scriptSource).toContain('test("sum", () => {')
expect(result.scriptSource).toContain('expect(1 + 1).toBe(2)')
if (viteVersion[0] >= '6') {
// vite ssr transform wraps import by
// __vite_ssr_identity__(__vite_ssr_import_0__.test)(...)
expect(result.scriptSource).toContain('test)("sum", () => {')
expect(result.scriptSource).toContain('expect)(1 + 1).toBe(2)')
}
else {
expect(result.scriptSource).toContain('test("sum", () => {')
expect(result.scriptSource).toContain('expect(1 + 1).toBe(2)')
}

send({ method: 'Debugger.resume' })

Expand Down
6 changes: 4 additions & 2 deletions test/cli/test/stacktraces.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { resolve } from 'pathe'
import { glob } from 'tinyglobby'
import { describe, expect, it } from 'vitest'

import { version as viteVersion } from 'vite'
import { describe, expect, it as vitestIt } from 'vitest'
import { runVitest } from '../../test-utils'

const [major] = process.version.slice(1).split('.').map(num => Number(num))

const it = viteVersion[0] >= '6' ? (vitestIt.skip as typeof vitestIt) : vitestIt

// To prevent the warnining coming up in snapshots
process.setMaxListeners(20)

Expand Down
7 changes: 6 additions & 1 deletion test/coverage-test/test/vue.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { readdirSync } from 'node:fs'
import { resolve } from 'node:path'
import { version as viteVersion } from 'vite'
import { beforeAll, expect } from 'vitest'
import { isBrowser, isV8Provider, readCoverageMap, runVitest, test } from '../utils'

Expand All @@ -20,7 +21,11 @@ test('files should not contain query parameters', () => {
expect(files).not.toContain('Counter.component.ts?vue&type=script&src=true&lang.ts.html')
})

test('coverage results matches snapshot', async () => {
test('coverage results matches snapshot', async (ctx) => {
if (viteVersion[0] >= '6') {
ctx.skip()
}

const coverageMap = await readCoverageMap()
const summary = coverageMap.getCoverageSummary()

Expand Down