{"id":15412824,"url":"https://github.com/jeetiss/react-pdf-testing-library","last_synced_at":"2025-06-12T18:06:42.696Z","repository":{"id":45727572,"uuid":"354348655","full_name":"jeetiss/react-pdf-testing-library","owner":"jeetiss","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-16T11:27:54.000Z","size":2440,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T01:42:23.017Z","etag":null,"topics":["demo","pdf","testing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeetiss.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-03T17:07:36.000Z","updated_at":"2024-12-17T12:42:16.000Z","dependencies_parsed_at":"2024-09-18T22:09:13.385Z","dependency_job_id":null,"html_url":"https://github.com/jeetiss/react-pdf-testing-library","commit_stats":{"total_commits":44,"total_committers":1,"mean_commits":44.0,"dds":0.0,"last_synced_commit":"b4183e358ade1ca396a2c6e2b4fe4780f99a99d6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeetiss%2Freact-pdf-testing-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeetiss%2Freact-pdf-testing-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeetiss%2Freact-pdf-testing-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeetiss%2Freact-pdf-testing-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeetiss","download_url":"https://codeload.github.com/jeetiss/react-pdf-testing-library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249685196,"owners_count":21310564,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["demo","pdf","testing"],"created_at":"2024-10-01T16:54:32.283Z","updated_at":"2025-04-19T11:35:59.362Z","avatar_url":"https://github.com/jeetiss.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-pdf-testing-library\n\nSet of helpers for `react-pdf` visual testing with `jest-image-snapshot`.\n\n## Usage\n\n```bash\nnpm i -D react-pdf-testing-library\n```\n\n```js\nimport { Resume } from '..'\nimport { renderDocument } from 'react-pdf-testing-library'\n\nit('should work', async () =\u003e {\n  const document = await renderDocument(\u003cResume /\u003e)\n\n  expect(document.pagesNumber).toBe(2)\n  expect(await document.page(0).imageSnapshot()).toMatchImageSnapshot()\n  expect(await document.page(1).imageSnapshot()).toMatchImageSnapshot()\n})\n```\n\n# API\n\n## renderComponent\n\ntakes react-pdf component and size of page and returns helpers.\n\n```js\nconst wrapper = await renderComponent(\u003cComponent /\u003e, { size: 'A5' })\n```\n\n\u003e Size is optional. can be string (`A2`, `A3`, `A4`) or tuple (`[number, number]`) with width and height size in pixels. default value is `A4`\n\n### imageSnapshot\n\nreturns raw png image of the component. \n\n```js\nconst wrapper = await renderComponent(\u003cComponent /\u003e)\n\nexpect(await wrapper.imageSnapshot()).toMatchImageSnapshot()\n```\n\n### containsLinkTo\n\nchecks that link with href exists in the component.\n\n```js\nconst wrapper = await renderComponent(\u003cComponent /\u003e)\n\nexpect(await wrapper.containsLinkTo('https://example.com')).toBe(true)\n```\n\n### containsAnchorTo\n\nchecks that component contains goto construction with specified id.\n\n```js\nconst wrapper = await renderComponent(\u003cComponent /\u003e)\n\nexpect(await wrapper.containsAnchorTo('#myDest')).toBe(true)\n```\n\n## renderDocument\n\ntakes react-pdf component or raw pdf and returns document helpers.\n\n### pagesNumber\n\nreturns amount of pages in pdf.\n\n```js\nconst document = await renderDocument(\u003cComponent /\u003e)\n\nexpect(document.pagesNumber).toBe(10)\n```\n\n### page\n\nreturns object with `imageSnapshot`, `containsLinkTo` and `containsAnchorTo` helpers for page with specified index, index starts from 0.\n\n\u003e helpers run over selected page\n\n```js\nconst document = await renderDocument(\u003cComponent /\u003e)\n\nexpect(await document.page(0).imageSnapshot()).toMatchImageSnapshot()\nexpect(await document.page(1).containsAnchorTo('#myDest')).toBe(true)\nexpect(await document.page(2).containsLinkTo('https://example.com')).toBe(true)\n```\n\n## Build\n\nClone this repo, `cd` into it, make sure you’re using Node 12+, and then:\n\n```sh\nnpm i\nnpm run build\n```\n\n## Run\n\nThen run jest\n\n```sh\nnpm test\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeetiss%2Freact-pdf-testing-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeetiss%2Freact-pdf-testing-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeetiss%2Freact-pdf-testing-library/lists"}