[BUG] VSCode freezes on file change in large repo #1196
Description
Describe the bug
VSCode freezes when making a file change (create / rename / delete) in a repo with lots of tests.
To Reproduce
Steps to reproduce the behavior:
- Clone repo with many test files:
git clone https://github.com/christianvuerings/vscode-jest-large-repo.git
- Open VSCode with that repo:
cd vscode-jest-large-repo; code .
- Run all tests in test explorer (running just 1 test also repros the issue)
- After tests finish to run, rename a non-test file
src/main.js
tosrc/main_renamed.js
:mv src/main.js src/main_renamed.js
Expected behavior
VSCode doesn't freeze
Actual behavior
VSCode freezes for 5-10 seconds
Screenshots
If applicable, add screenshots to help explain your problem.
First part: shows freezing issue with 2 separate renames.
Second part: renaming works smoothly without the VSCode Jest extension
vscode-jest-free-file-rename.mp4
Environment:
- vscode-jest version:
v6.4.0
node -v
:v18.16.1
npm -v
oryarn --version
:9.5.1
- jest or react-scripts (if you haven’t ejected) version:
Jest 29.7.0
- your vscode-jest settings:
- jest.jestCommandLine?
None
- jest.runMode?
on-demand
- jest.outputConfig?
None
- anything else that you think might be relevant? Set
deferred
totrue
- jest.jestCommandLine?
- Operating system:
Mac OS 14.6.1
Prerequisite
- are you able to run jest from the command line?
Yes
- where do you run jest CLI from?
Root directory of the project
- how do you run your tests from the command line?
npm run test
Additional context
Add any other context about the problem here.
When debugging the root cause seems to be updateTestFileList
:
vscode-jest/src/JestExt/core.ts
Lines 744 to 765 in fae16e8
Which gets called on every file create, delete or rename
vscode-jest/src/JestExt/core.ts
Lines 767 to 775 in fae16e8
If we comment out the contents of updateTestFileList
everything works smoothly