From 07de129823831335251d9c7eee01664e0649a6e7 Mon Sep 17 00:00:00 2001 From: yoho <907415276@qq.com> Date: Tue, 25 Oct 2022 17:32:01 +0800 Subject: [PATCH] fix(reporter): load custom reporter using `executeFile` (#2184) * fix: load file by @fs * fix: window * chore: update Co-authored-by: Anthony Fu * fix: path * fix: test Co-authored-by: Anthony Fu --- packages/vitest/src/node/reporters/utils.ts | 2 +- test/reporters/tests/utils.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vitest/src/node/reporters/utils.ts b/packages/vitest/src/node/reporters/utils.ts index aad3aa695c88..ed7e433d400d 100644 --- a/packages/vitest/src/node/reporters/utils.ts +++ b/packages/vitest/src/node/reporters/utils.ts @@ -6,7 +6,7 @@ import type { BenchmarkBuiltinReporters, BuiltinReporters } from './index' async function loadCustomReporterModule(path: string, runner: ViteNodeRunner): Promise C> { let customReporterModule: { default: new () => C } try { - customReporterModule = await runner.executeId(path) + customReporterModule = await runner.executeFile(path) } catch (customReporterModuleError) { throw new Error(`Failed to load custom Reporter from ${path}`, { cause: customReporterModuleError as Error }) diff --git a/test/reporters/tests/utils.test.ts b/test/reporters/tests/utils.test.ts index 24aa83510f4d..e41b71ca62fc 100644 --- a/test/reporters/tests/utils.test.ts +++ b/test/reporters/tests/utils.test.ts @@ -10,7 +10,7 @@ import TestReporter from '../src/custom-reporter' const customReporterPath = resolve(__dirname, '../src/custom-reporter.js') const fetchModule = { - executeId: (id: string) => import(id), + executeFile: (id: string) => import(id), } as ViteNodeRunner describe('Reporter Utils', () => {