full-page-capture.test.js
1 /** 2 * Tests for src/reports/full-page-capture.js 3 * 4 * This module is heavily Playwright-dependent, so we test: 5 * - Module exports exist and are correct types 6 * - captureFullPage rejects with meaningful errors when called without a browser 7 * 8 * Browser-based integration testing is out of scope for unit tests. 9 */ 10 11 import { test, describe } from 'node:test'; 12 import assert from 'node:assert/strict'; 13 14 import { captureFullPage } from '../../src/reports/full-page-capture.js'; 15 16 describe('full-page-capture module exports', () => { 17 test('captureFullPage is exported as a function', () => { 18 assert.equal(typeof captureFullPage, 'function'); 19 }); 20 }); 21 22 describe('captureFullPage — error handling', () => { 23 test('rejects when given an invalid URL (browser launch will fail or URL is unreachable)', async () => { 24 // This exercises the error handling path — the browser will either fail to 25 // launch (if Playwright is not installed) or the navigation will fail. 26 // Either way, the function should reject, not hang. 27 await assert.rejects( 28 captureFullPage('not-a-valid-url', { timeout: 3000 }), 29 // Accept any error — the point is it rejects, not hangs 30 ); 31 }); 32 });