From d8215ac40efbe395365ad729d32ba4659d0d68e1 Mon Sep 17 00:00:00 2001 From: Suvesh Moza Date: Mon, 26 Oct 2026 02:19:34 +0530 Subject: [PATCH] test(wxt): assert offline-check failures instead of logging them Signed-off-by: Suvesh Moza --- .../__tests__/network-utils.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/wxt/src/internal-utils/__tests__/network-utils.test.ts b/packages/wxt/src/internal-utils/__tests__/network-utils.test.ts index 8714d56f8..8345e1158 100644 --- a/packages/wxt/src/internal-utils/__tests__/network-utils.test.ts +++ b/packages/wxt/src/internal-utils/__tests__/network-utils.test.ts @@ -2,6 +2,7 @@ import { describe, expect, it, vi } from 'vitest'; import * as dns from 'node:dns'; import { isOnline, fetchCached } from '../network-utils'; import { ResolvedConfig } from '../../types'; +import consola from 'consola'; type DnsCallback = (err: NodeJS.ErrnoException | null) => void; @@ -10,6 +11,12 @@ vi.mock('node:dns'); const fetchMock = vi.fn(); global.fetch = fetchMock; +vi.mock('consola', () => ({ + default: { + error: vi.fn(), + }, +})); + describe('Network utils', () => { describe('isOnline', () => { it('should return true when online', async () => { @@ -43,6 +50,10 @@ describe('Network utils', () => { const result = await isOnline(); expect(result).toBe(false); + expect(consola.error).toHaveBeenCalledWith( + 'Error checking offline status:', + 'Promise timed out after 1000ms', + ); }); it('should handle dns.resolve errors gracefully', async () => { @@ -52,6 +63,10 @@ describe('Network utils', () => { const result = await isOnline(); expect(result).toBe(false); + expect(consola.error).toHaveBeenCalledWith( + 'Error checking offline status:', + expect.objectContaining({ message: 'DNS resolution failed' }), + ); }); });