fix(vm-threads): tests not cancelled on key press, cancelled tests shown twice#4781
Conversation
✅ Deploy Preview for fastidious-cascaron-4ded94 canceled.
|
|
There's still one more bug to fix. Once tests have been interrupted and are re-run, the "skip status" of the tests is not reseted. Earlier this line has done it: Skip status is set here: vitest/packages/vitest/src/node/state.ts Lines 153 to 168 in 9497f48 This bug is present on all pools. |
| for (const path of paths) { | ||
| if (isCancelled) { | ||
| ctx.state.cancelFiles(files.slice(paths.indexOf(path)), ctx.config.root, project.getName()) | ||
| ctx.state.cancelFiles(files.slice(paths.indexOf(path)), ctx.config.root, project.config.name) |
There was a problem hiding this comment.
This needs to match with the collected files:
vitest/packages/runner/src/collect.ts
Line 28 in 9497f48
This feels a bit hacky. The WorkspaceProject.getSerializableConfig() always returns undefined for .name instead of '' when there's no name set for the project (no workspaces used).
The state.clearFiles uses the projectName when comparing files. When they don't match, there can be duplicate entries where one is from collection and one from cancelling:
'/x/vitest-example-project/vitest/test/sum.2.test.js' => [
{
filepath: '/x/vitest-example-project/vitest/test/sum.2.test.js',
id: '/x/vitest-example-project/vitest/test/sum.2.test.js',
mode: 'skip', // <-- From test cancel
name: 'test/sum.2.test.js',
projectName: '',
type: 'suite',
...
},
{
filepath: '/x/vitest-example-project/vitest/test/sum.2.test.js',
mode: 'run', // <-- From test collect
name: 'test/sum.2.test.js',
type: 'suite',
...
}
],These show up in reports like below:
Description
pool: 'vmThreads'.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.