{"id":40911722,"url":"https://github.com/btravers/pdf-snapshot","last_synced_at":"2026-01-22T03:05:49.754Z","repository":{"id":60452261,"uuid":"541750982","full_name":"btravers/pdf-snapshot","owner":"btravers","description":"Jest matcher for visual regression testing of PDF documents","archived":false,"fork":false,"pushed_at":"2023-07-18T12:23:01.000Z","size":188,"stargazers_count":11,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-27T14:52:02.773Z","etag":null,"topics":["canvas","docker","jest","nodejs","pdf","pdfjs","snapshot","test","testing","trpc","typescript","visual-regression-testing"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/btravers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-09-26T19:28:14.000Z","updated_at":"2024-09-16T14:35:39.000Z","dependencies_parsed_at":"2024-10-10T12:02:16.632Z","dependency_job_id":"d4c13c66-7fca-4639-9485-e2e2545c1ec9","html_url":"https://github.com/btravers/pdf-snapshot","commit_stats":{"total_commits":32,"total_committers":1,"mean_commits":32.0,"dds":0.0,"last_synced_commit":"c4b9dc949625d5a2fb84de93543a256df5e4a101"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/btravers/pdf-snapshot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btravers%2Fpdf-snapshot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btravers%2Fpdf-snapshot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btravers%2Fpdf-snapshot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btravers%2Fpdf-snapshot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/btravers","download_url":"https://codeload.github.com/btravers/pdf-snapshot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btravers%2Fpdf-snapshot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28651824,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["canvas","docker","jest","nodejs","pdf","pdfjs","snapshot","test","testing","trpc","typescript","visual-regression-testing"],"created_at":"2026-01-22T03:05:49.434Z","updated_at":"2026-01-22T03:05:49.743Z","avatar_url":"https://github.com/btravers.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PDF Snapshot\n\n![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/btravers/pdf-snapshot/ci/main?logo=githubactions)\n![npm](https://img.shields.io/npm/v/@btravers/pdf-snapshot-jest?color=g\u0026label=version\u0026logo=npm)\n![Docker Image Version (latest semver)](https://img.shields.io/docker/v/btravers/pdf-snapshot?color=g\u0026logo=docker)\n![GitHub](https://img.shields.io/github/license/btravers/pdf-snapshot?color=g)\n\nJest matcher for visual regression testing of PDF documents. \nBehaves just like [Jest snapshots](https://facebook.github.io/jest/docs/snapshot-testing.html) do.\n\nUnder the hood, it uses [pdf.js](https://github.com/mozilla/pdf.js) for conversion of a pdf to png. \nIn node, pdf.js depends on [canvas](https://github.com/Automattic/node-canvas).\nFinally, the comparison is happening via [pixelmatch](https://github.com/mapbox/pixelmatch).\n\nIn order to be platform agnostic, the png conversion and png comparison is performed by a small server running aside, available as a [Docker image](https://hub.docker.com/r/btravers/pdf-snapshot) and communicating with Jest matcher using [tRCP](https://github.com/trpc/trpc). \n\n## Usage\n\n### Prerequisites\n\nBefore you begin, ensure you have met the following requirements:\n\n- You have installed the latest version of Docker.\n\n### Installation\n\nFirst pull the Docker image of the main service.\n```sh\ndocker pull btravers/pdf-snapshot\n```\n\nThen install Jest matcher in the dev dependencies of your project.\n\n```sh\nnpm install --save-dev @btravers/pdf-snapshot-jest\n```\n\nPlease note that Jest 28 is a peerDependency. \n\nDeclare `toMatchPdfSnapshot` matcher in your Jest configuration.\n\n```json\n\"jest\": {\n  \"setupFilesAfterEnv\": [\n    \"@btravers/pdf-snapshot-jest/dist/toMatchPdfSnapshot\"\n  ]\n}\n```\n\nIf you are using **Typescript** add `import('@btravers/pdf-snapshot-jest/dist/toMatchPdfSnapshot');` to your typings.\n\n### Invocation\n\nStart the container with the main service.\n\n```sh\ndocker run -d -p 3000:3000 btravers/pdf-snapshot\n```\n\nIn your test, export `PDF_SNAPSHOT_SERVER_URL` environment variable in order to link Jest matcher with the service running in the container.\n```js\nprocess.env.PDF_SNAPSHOT_SERVER_URL = 'http://localhost:3000'\n```\n\nNow, all you have to do in your tests is pass a pdf content as Buffer.\n\n```ts\nconst pdfBuffer = await fs.promise.readFile('path to your pdf');\ndescribe('test pdf report visual regression', () =\u003e {\n  it('should match', () =\u003e expect(pdfBuffer).toMatchPdfSnapshot());\n});\n```\n\n### Go further\n\nYou can rely on [testcontainers-node](https://github.com/testcontainers/testcontainers-node) and automate the container start before tests run.\n\n## Credits\n\n- [pdf-visual-diff](https://github.com/moshensky/pdf-visual-diff)\n- [jest-image-snapshot](https://github.com/americanexpress/jest-image-snapshot)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbtravers%2Fpdf-snapshot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbtravers%2Fpdf-snapshot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbtravers%2Fpdf-snapshot/lists"}