From 233492be0a23e7cdaa2370e01c8e089e4ff0b957 Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Thu, 11 Jan 2024 15:21:51 +0100 Subject: [PATCH] test: cleanup --- test/reporters/tests/utils.test.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/reporters/tests/utils.test.ts b/test/reporters/tests/utils.test.ts index f5322fe651b3..35951cc7bdea 100644 --- a/test/reporters/tests/utils.test.ts +++ b/test/reporters/tests/utils.test.ts @@ -3,6 +3,7 @@ */ import { resolve } from 'pathe' import type { ViteNodeRunner } from 'vite-node/client' +import type { Vitest } from 'vitest' import { describe, expect, test } from 'vitest' import { createReporters } from '../../../packages/vitest/src/node/reporters/utils' import { DefaultReporter } from '../../../packages/vitest/src/node/reporters/default' @@ -12,29 +13,32 @@ const customReporterPath = resolve(__dirname, '../src/custom-reporter.js') const fetchModule = { executeId: (id: string) => import(id), } as ViteNodeRunner +const ctx = { + runner: fetchModule, +} as Vitest describe('Reporter Utils', () => { test('passing an empty array returns nothing', async () => { - const promisedReporters = await createReporters([], fetchModule) + const promisedReporters = await createReporters([], ctx) expect(promisedReporters).toHaveLength(0) }) test('passing the name of a single built-in reporter returns a new instance', async () => { - const promisedReporters = await createReporters(['default'], fetchModule) + const promisedReporters = await createReporters(['default'], ctx) expect(promisedReporters).toHaveLength(1) const reporter = promisedReporters[0] expect(reporter).toBeInstanceOf(DefaultReporter) }) test('passing in the path to a custom reporter returns a new instance', async () => { - const promisedReporters = await createReporters(([customReporterPath]), fetchModule) + const promisedReporters = await createReporters(([customReporterPath]), ctx) expect(promisedReporters).toHaveLength(1) const customReporter = promisedReporters[0] expect(customReporter).toBeInstanceOf(TestReporter) }) test('passing in a mix of built-in and custom reporters works', async () => { - const promisedReporters = await createReporters(['default', customReporterPath], fetchModule) + const promisedReporters = await createReporters(['default', customReporterPath], ctx) expect(promisedReporters).toHaveLength(2) const defaultReporter = promisedReporters[0] expect(defaultReporter).toBeInstanceOf(DefaultReporter)