From 31c535cd49a41a90b05e29d2b989285c8abe2481 Mon Sep 17 00:00:00 2001 From: Ricardo Gobbo de Souza Date: Thu, 18 May 2023 10:36:25 -0300 Subject: [PATCH] test: update --- test/warn.test.ts | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/test/warn.test.ts b/test/warn.test.ts index a73b0bd..3ad22bf 100644 --- a/test/warn.test.ts +++ b/test/warn.test.ts @@ -1,27 +1,20 @@ -import { describe, test, expect, vi } from 'vitest' +import { describe, test, expect, vi, afterAll } from 'vitest' import { setup } from '@nuxt/test-utils' -import consola from 'consola' -export function mockLogger (): typeof consola { - const mock = {} +describe('warn', async () => { + const spyStderr = vi.spyOn(process.stderr, 'write').mockImplementation(() => undefined!) - consola.mockTypes((type) => { - mock[type] = mock[type] || vi.fn() - return mock[type] + afterAll(() => { + spyStderr.mockRestore() }) - // @ts-ignore - return mock -} - -const logger = mockLogger() - -describe('warn', async () => { await setup({ server: false }) test('should warn if no provided fonts', () => { - expect(logger.warn).toHaveBeenCalledWith('No provided fonts.') + expect(spyStderr).toBeCalledTimes(1) + const output = spyStderr.mock.calls[0][0].toString() + expect(output).contains('[warn] [nuxt:google-fonts] No provided fonts.') }) })