From 51b0b303db745887ba78e98bdfca93f86d68fcec Mon Sep 17 00:00:00 2001 From: AriPerkkio Date: Tue, 9 May 2023 12:58:12 +0300 Subject: [PATCH] fix(reporter): prevent deleting test reports stored in coverage directory --- packages/vitest/src/node/core.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/vitest/src/node/core.ts b/packages/vitest/src/node/core.ts index 0ec32306e3e4..bdbe27f6bf0d 100644 --- a/packages/vitest/src/node/core.ts +++ b/packages/vitest/src/node/core.ts @@ -285,11 +285,14 @@ export class Vitest { return } - await this.report('onInit', this) - - await this.initCoverageProvider() - await this.coverageProvider?.clean(this.config.coverage.clean) - await this.initBrowserProviders() + try { + await this.initCoverageProvider() + await this.coverageProvider?.clean(this.config.coverage.clean) + await this.initBrowserProviders() + } + finally { + await this.report('onInit', this) + } const files = await this.filterTestsBySource( await this.globTestFiles(filters),