import { describe, expect, test } from 'vitest'; import { Document, Page, View, Text, Font } from '@react-pdf/renderer'; import renderToImage from './renderComponent'; // pdf.js does not render default fonts in node and I use Open Sans (: Font.register({ family: 'Open Sans', src: 'https://fonts.gstatic.com/s/opensans/v17/mem8YaGs126MiZpBA-UFVZ0e.ttf', }); describe('debug', () => { test('should show size of Text component', async () => { const image = await renderToImage( hello , ); expect(image).toMatchImageSnapshot(); }); test('should show paddings and margins', async () => { const image = await renderToImage( a b c , ); expect(image).toMatchImageSnapshot(); }); test('should show origin pointer', async () => { const image = await renderToImage( hello , ); expect(image).toMatchImageSnapshot(); }); test('should not render debug if false passed', async () => { const image = await renderToImage( hello , ); expect(image).toMatchImageSnapshot(); }); test('should not render debug if undefined passed', async () => { const image = await renderToImage( hello , ); expect(image).toMatchImageSnapshot(); }); });