beforeEach((context) => {
console.log(context.task.name);
console.log(context.task.parent.name);
});
or
beforeEach(({task}) => {
console.log(task.name);
console.log(task.parent.name);
});
Either should work. See Vitest's context documentation for more information. You can find more documentation about parent and other options like fullName at Vitest's TestCase page. If you need to go up more than one level, parent can do that.
Note that the documentation is talking about doing it in a test, but at the bottom, it talks about accessing context in a beforeEach. It's a bit odd in that you'd usually put test-specific behavior in the test block, not the beforeEach. However, the context is available for modification in the beforeEach and is supposed to be available for access as well.