vscode
vscode copied to clipboard
Sometimes Vitest extension runs cached tests
Describe the bug
I've noticed that sometimes my tests fail when running them from the VS Code extension. In the screenshot below, you can see a mismatch between my actual test description ("fixes imports from index files") vs. what was run by the Vitest extension ("adds imports from barrel files", which was the previous test description). This indicates a caching problem.
Reproduction
For me this happens when I rename my test snapshot files.
Here is the testing code that I used:
describe('convertFile', () => {
const fixtures = path.join(process.cwd(), 'src', 'test', 'fixtures');
it('fixes imports from index files', async () => {
const projectDir = path.join(fixtures, 'index-import');
const projectConfig = path.join(projectDir, 'tsconfig.json');
const snapshot = path.join(projectDir, 'main.snap.ts');
const project = ProjectUtil.getProject(projectConfig);
const modifiedFile = convertFile(project, project.getSourceFile('main.ts')!, true);
await expect(modifiedFile.getText()).toMatchFileSnapshot(snapshot);
});
});
Output
[INFO 10:47:54 AM] [v1.6.1] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 10:47:54 AM] [API] Running Vitest v2.1.3 (dist/vitest.config.js) with [email protected]: /home/bennycode/.nvm/versions/node/v20.17.0/bin/node
[INFO 10:47:54 AM] [API] Running Vitest v2.1.3 (ts2esm/vitest.config.ts) with [email protected]: /home/bennycode/.nvm/versions/node/v20.17.0/bin/node
[INFO 10:47:54 AM] [API] Vitest v2.1.3 (dist/vitest.config.js) child process 15631 created
[INFO 10:47:54 AM] [API] Vitest v2.1.3 (ts2esm/vitest.config.ts) child process 15632 created
[INFO 10:47:54 AM] [VSCODE] Watching ts2esm with pattern **/*
[INFO 10:50:29 AM] [API] Collecting tests: src/converter/convertFile.test.ts
Version
v1.6.1
Validations
- [X] Check that you are using the latest version of the extension
- [X] Check that there isn't already an issue 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 or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.