Skip to content

Commit 73b10f1

Browse files
authored
feat(ui): allow run individual test/suites (#9465)
1 parent 5db54a4 commit 73b10f1

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

packages/ui/client/composables/client/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ function clearTaskResult(task: RunnerTask) {
9494
const node = explorerTree.nodes.get(task.id)
9595
if (node) {
9696
node.state = undefined
97+
// update task mode to allow change icon on skipped tests
98+
task.mode = 'run'
9799
node.duration = undefined
98100
if (isTaskSuite(task)) {
99101
for (const t of task.tasks) {
@@ -113,13 +115,15 @@ function clearResults(useFiles: RunnerTestFile[]) {
113115
const task = map.get(i.id)
114116
if (task) {
115117
task.state = undefined
118+
task.mode = 'run'
116119
task.duration = undefined
117120
}
118121
}
119122
})
120123
const file = map.get(f.id)
121124
if (file) {
122125
file.state = undefined
126+
file.mode = 'run'
123127
file.duration = undefined
124128
if (isFileNode(file)) {
125129
file.collectDuration = undefined

packages/vitest/src/node/core.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,12 +1071,24 @@ export class Vitest {
10711071
throw new Error(`Task ${id} was not found`)
10721072
}
10731073

1074-
const taskNamePattern = task.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
1074+
const reportedTask = this.state.getReportedEntityById(id)
1075+
if (!reportedTask) {
1076+
throw new Error(`Test specification for task ${id} was not found`)
1077+
}
10751078

1076-
await this.changeNamePattern(
1077-
taskNamePattern,
1078-
[task.file.filepath],
1079-
'tasks' in task ? 'rerun suite' : 'rerun test',
1079+
const specifications = [reportedTask.toTestSpecification()]
1080+
await Promise.all([
1081+
this.report(
1082+
'onWatcherRerun',
1083+
[task.file.filepath],
1084+
'tasks' in task ? 'rerun suite' : 'rerun test',
1085+
),
1086+
...this._onUserTestsRerun.map(fn => fn(specifications)),
1087+
])
1088+
await this.runFiles(specifications, false)
1089+
await this.report(
1090+
'onWatcherStart',
1091+
['module' in reportedTask ? reportedTask.module.task : reportedTask.task],
10801092
)
10811093
}
10821094

0 commit comments

Comments
 (0)