Skip to content

Commit

Permalink
fix: update required minimal vitest version
Browse files Browse the repository at this point in the history
  • Loading branch information
zxch3n committed Jun 19, 2022
1 parent 4d98f12 commit 3f8c817
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Requirements

- Require VSCode's version >= July 2021 (version 1.59).
- Require Vitest's version >= v0.8.0
- Require Vitest's version >= v0.12.0

# Config

Expand Down
2 changes: 1 addition & 1 deletion samples/monorepo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"devDependencies": {
"happy-dom": "^2.49.0",
"vitest": "^0.8.0"
"vitest": "^0.12.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ export async function getVitestWorkspaceConfigs(): Promise<VitestWorkspaceConfig
}

function isCompatibleVitestConfig(config: Pick<VitestWorkspaceConfig, 'version' | 'workspace'>) {
return !!((config.version && semver.gte(config.version, '0.8.0')) || getConfig(config.workspace).commandLine)
return !!((config.version && semver.gte(config.version, '0.12.0')) || getConfig(config.workspace).commandLine)
}
10 changes: 4 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function activate(context: vscode.ExtensionContext) {
const fileDiscoverer = registerDiscovery(ctrl, context)

const workspaceConfigs = await getVitestWorkspaceConfigs()
// enable run/debug/watch tests only if vitest version >= 0.8.0
// enable run/debug/watch tests only if vitest version >= 0.12.0
if (!workspacesCompatibilityCheck(workspaceConfigs, context))
return

Expand All @@ -55,12 +55,12 @@ function workspacesCompatibilityCheck(workspaceConfigs: VitestWorkspaceConfig[],
})

workspaceConfigs.filter(x => !x.isCompatible).forEach((config) => {
vscode.window.showWarningMessage(`Because Vitest version < 0.8.0 for ${config.workspace.name} `
vscode.window.showWarningMessage(`Because Vitest version < 0.12.0 for ${config.workspace.name} `
+ ', run/debug/watch tests from Vitest extension disabled for that workspace.\n')
})

if (workspaceConfigs.every(x => !x.isCompatible)) {
const msg = 'Because Vitest version < 0.8.0 for every workspace folder, run/debug/watch tests from Vitest extension disabled.\n'
const msg = 'Because Vitest version < 0.12.0 for every workspace folder, run/debug/watch tests from Vitest extension disabled.\n'
context.subscriptions.push(
vscode.commands.registerCommand(Command.ToggleWatching, () => {
vscode.window.showWarningMessage(msg)
Expand All @@ -69,9 +69,7 @@ function workspacesCompatibilityCheck(workspaceConfigs: VitestWorkspaceConfig[],
vscode.window.showWarningMessage(msg)
}),
)
// v0.8.0 introduce a breaking change in json format
// https://github.com/vitest-dev/vitest/pull/1034
// so we need to disable run & debug in version < 0.8.0

vscode.window.showWarningMessage(msg)
return false
}
Expand Down

0 comments on commit 3f8c817

Please sign in to comment.