Skip to content

Commit

Permalink
fix(reporter): load custom reporter using executeFile (#2184)
Browse files Browse the repository at this point in the history
* fix: load file by @fs

* fix: window

* chore: update

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>

* fix: path

* fix: test

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
poyoho and antfu committed Oct 25, 2022
1 parent dc00ae7 commit 07de129
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/vitest/src/node/reporters/utils.ts
Expand Up @@ -6,7 +6,7 @@ import type { BenchmarkBuiltinReporters, BuiltinReporters } from './index'
async function loadCustomReporterModule<C extends Reporter>(path: string, runner: ViteNodeRunner): Promise<new () => 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 })
Expand Down
2 changes: 1 addition & 1 deletion test/reporters/tests/utils.test.ts
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 07de129

Please sign in to comment.