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: print unexpected error message if peer dependencies have a different version #6446

Merged
merged 2 commits into from
Sep 5, 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
1 change: 1 addition & 0 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"magic-string": "^0.30.11",
"msw": "^2.3.5",
"sirv": "^2.0.4",
"tinyrainbow": "^1.2.0",
"ws": "^8.18.0"
},
"devDependencies": {
Expand Down
12 changes: 12 additions & 0 deletions packages/browser/src/node/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { WorkspaceProject } from 'vitest/node'
import type { Plugin } from 'vitest/config'
import { createServer } from 'vitest/node'
import c from 'tinyrainbow'
import { version } from '../../package.json'
import { setupBrowserRpc } from './rpc'
import { BrowserServer } from './server'
import BrowserPlugin from './plugin'
Expand All @@ -14,6 +16,16 @@ export async function createBrowserServer(
prePlugins: Plugin[] = [],
postPlugins: Plugin[] = [],
) {
if (project.ctx.version !== version) {
project.ctx.logger.warn(
c.yellow(
`Loaded ${c.inverse(c.yellow(` vitest@${project.ctx.version} `))} and ${c.inverse(c.yellow(` @vitest/browser@${version} `))}.`
+ '\nRunning mixed versions is not supported and may lead into bugs'
+ '\nUpdate your dependencies and make sure the versions match.',
),
)
}

const server = new BrowserServer(project, '/')

const configPath = typeof configFile === 'string' ? configFile : false
Expand Down
14 changes: 13 additions & 1 deletion packages/ui/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@ import { basename, resolve } from 'pathe'
import sirv from 'sirv'
import type { Plugin } from 'vite'
import { coverageConfigDefaults } from 'vitest/config'
import type { Vitest } from 'vitest'
import type { Vitest } from 'vitest/node'
import { toArray } from '@vitest/utils'
import c from 'tinyrainbow'
import { version } from '../package.json'

export default (ctx: Vitest): Plugin => {
if (ctx.version !== version) {
ctx.logger.warn(
c.yellow(
`Loaded ${c.inverse(c.yellow(` vitest@${ctx.version} `))} and ${c.inverse(c.yellow(` @vitest/ui@${version} `))}.`
+ '\nRunning mixed versions is not supported and may lead into bugs'
+ '\nUpdate your dependencies and make sure the versions match.',
),
)
}

return <Plugin>{
name: 'vitest:ui',
apply: 'serve',
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading