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

"this.ctx.handleFileChanged is not a function" error stopping tests refreshing with latest Vitest beta, 3.0.0-beta.2 #562

Open
seaders opened this issue Dec 17, 2024 · 0 comments

Comments

@seaders
Copy link

seaders commented Dec 17, 2024

Describe the bug

The format of Vitest from vitest/node has changed with Vitest's latest beta and handleFileChanged has been removed in this commit, vitest-dev/vitest@9a1b501#diff-c70ce04cc623628f74475cbde7bf56c29e5c3034b6fd5d26f737cb3944254463L984

99% of the extensions features still work fine with Vitest 3, but this pops up in the Vitest output window, and, if you make any changes to your test file, they won't show up.

[INFO 16:03:50] [API] Running Vitest v3.0.0-beta.2 (shopifyFunctions/vite.config.mts) with [email protected]: /Users/seaders/.nvm/versions/node/v20.11.1/bin/node 
[INFO 16:03:51] [API] Vitest v3.0.0-beta.2 (shopifyFunctions/vite.config.mts) child process 89694 created
[INFO 16:03:51] [API] Watching /Users/Shared/Developer/workspaces/extensions/firebase/shopifyFunctions/vite.config.mts
[INFO 16:03:51] [VSCODE] Watching shopifyFunctions with pattern **/*
[INFO 16:03:51] [API] Collecting tests: test/local/auth.spec.ts
[16:03:51] Not starting the runner because tests are being collected for test/local/auth.spec.ts
[16:03:53] There is no test run for "auth.spec.ts"
[16:03:53] No test run to finish for test/local/auth.spec.ts
[16:03:53] [VSCODE] Ignoring file: node_modules/.vite/results.json

[16:04:00] [VSCODE] File changed: test/local/auth.spec.ts
[INFO 16:04:01] [Worker] Error during analyzing changed files TypeError: this.ctx.handleFileChanged is not a function
    at e.handleFileChanged (/Users/seaders/.vscode/extensions/vitest.explorer-1.8.5/dist/worker.js:21:3899)
    at e.onFilesChanged (/Users/seaders/.vscode/extensions/vitest.explorer-1.8.5/dist/worker.js:21:4294)
    at process.S (/Users/seaders/.vscode/extensions/vitest.explorer-1.8.5/dist/worker.js:8:28753)
    at process.emit (node:events:518:28)
    at emit (node:internal/child_process:951:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

This causes a situation where,

  • if you change the name of a test and try to run it, it will try to run the old named test
  • if you add a new test, it isn't processed nor taken in, so can't be run
  • if you delete a test, but run the parent group, it tries to still run that test as well

Installing the previous version of vitest, or 2x, and restarting the extension fixes this.

Reproduction

With having [email protected] and [email protected], and a vite.config.ts file like,

/// <reference types="vitest/config" />

import { defineConfig } from "vite"
import tsconfigPaths from "vite-tsconfig-paths"

export default defineConfig({
  plugins: [tsconfigPaths()]
})

Create a test file - extension doesn't pick it up. Go to vitest sidebar, "Refresh tests", run that test file / some tests therein, add a new test - extension doesn't pick it up.

Output

[INFO 16:04:01] [Worker] Error during analyzing changed files TypeError: this.ctx.handleFileChanged is not a function
    at e.handleFileChanged (/Users/seaders/.vscode/extensions/vitest.explorer-1.8.5/dist/worker.js:21:3899)
    at e.onFilesChanged (/Users/seaders/.vscode/extensions/vitest.explorer-1.8.5/dist/worker.js:21:4294)
    at process.S (/Users/seaders/.vscode/extensions/vitest.explorer-1.8.5/dist/worker.js:8:28753)
    at process.emit (node:events:518:28)
    at emit (node:internal/child_process:951:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)


### Extension Version

1.8.5

### Vitest Version

3.0.0-beta.2

### Validations

- [X] Check that you are using the latest version of the extension
- [X] Check that there isn't [already an issue](https://github.com/vitest-dev/vscode/issues) that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitest-dev/vscode/discussions) or join our [Discord Chat Server](https://chat.vitest.dev).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant