{"_id":"@armandabric/pdf-snapshot-matcher","_rev":"2-3b0bf4276e4247decce9b88a769fd4a6","name":"@armandabric/pdf-snapshot-matcher","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"@armandabric/pdf-snapshot-matcher","version":"1.0.0","description":"PDF snapshot matcher","author":{"name":"Benoit TRAVERS"},"license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/armandabric/pdf-snapshot.git"},"keywords":["test","jest","expect","matcher","vitest","snapshot","pdf","visual testing"],"dependencies":{"@trpc/client":"10.0.0-rc.6","@trpc/server":"10.0.0-rc.6","dedent":"^0.7.0","lodash":"^4.17.21","rimraf":"^3.0.2"},"devDependencies":{"@types/dedent":"^0.7.0","@types/jest":"^29.2.2","@types/lodash":"^4.14.188","@types/node":"^18.11.9","@types/rimraf":"^3.0.2","expect":"^29.5.0","jest":"29.3.0","testcontainers":"^9.0.0","ts-jest":"^29.0.3","typescript":"^4.8.4","@armandabric/pdf-snapshot-service":"^0.0.1"},"peerDependencies":{"expect":">= 29"},"scripts":{"prebuild":"rimraf dist","build":"tsc -p tsconfig.build.json","test":"jest","test:debug":"DEBUG=testcontainers* jest"},"bugs":{"url":"https://github.com/armandabric/pdf-snapshot/issues"},"homepage":"https://github.com/armandabric/pdf-snapshot#readme","_id":"@armandabric/pdf-snapshot-matcher@1.0.0","_integrity":"sha512-IJmLSrrE9gCdJrVdfcvyoouDWJsz9KJRbmMPGfe7gorEBSri3c9MHmJMMkbZkOllPi6TMneRwbUzyIV5gHPiAw==","_resolved":"/tmp/e4d9af936d93a18338bd87a7cbaa3962/armandabric-pdf-snapshot-matcher-1.0.0.tgz","_from":"file:armandabric-pdf-snapshot-matcher-1.0.0.tgz","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-IJmLSrrE9gCdJrVdfcvyoouDWJsz9KJRbmMPGfe7gorEBSri3c9MHmJMMkbZkOllPi6TMneRwbUzyIV5gHPiAw==","shasum":"1f3f1d5984d174b8022ea47cc5fefd806852fa38","tarball":"https://registry.npmjs.org/@armandabric/pdf-snapshot-matcher/-/pdf-snapshot-matcher-1.0.0.tgz","fileCount":14,"unpackedSize":77461,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDGRmBHKs//+7OsekRkIe+yHgTZA+bpDFj1fbBbBSTAnwIhALCad3SNqI12V5L3dJIiP8H25ZH6B70AwoNzRdfxJTVJ"}]},"_npmUser":{"name":"spy-seth","email":"armand@forgebinaire.net"},"directories":{},"maintainers":[{"name":"spy-seth","email":"armand@forgebinaire.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pdf-snapshot-matcher_1.0.0_1687877446636_0.04413126803906464"},"_hasShrinkwrap":false},"1.1.0":{"name":"@armandabric/pdf-snapshot-matcher","version":"1.1.0","description":"PDF snapshot matcher","author":{"name":"Benoit TRAVERS"},"license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/armandabric/pdf-snapshot.git"},"keywords":["test","jest","expect","matcher","vitest","snapshot","pdf","visual testing"],"dependencies":{"@trpc/client":"10.0.0-rc.6","@trpc/server":"10.0.0-rc.6","dedent":"^0.7.0","lodash":"^4.17.21","rimraf":"^3.0.2"},"devDependencies":{"@types/dedent":"^0.7.0","@types/jest":"^29.2.2","@types/lodash":"^4.14.188","@types/node":"^18.11.9","@types/rimraf":"^3.0.2","expect":"^29.5.0","jest":"29.3.0","testcontainers":"^9.0.0","ts-jest":"^29.0.3","typescript":"^4.8.4","@armandabric/pdf-snapshot-service":"^0.0.1"},"peerDependencies":{"expect":">= 29"},"scripts":{"prebuild":"rimraf dist","build":"tsc -p tsconfig.build.json","test":"jest","test:debug":"DEBUG=testcontainers* jest"},"bugs":{"url":"https://github.com/armandabric/pdf-snapshot/issues"},"homepage":"https://github.com/armandabric/pdf-snapshot#readme","_id":"@armandabric/pdf-snapshot-matcher@1.1.0","_integrity":"sha512-2kzW5P5A8JYG6idy6OcwsOFuXC0ZWU1iTdqplJAZUsmzoG5Ya8m5CaVoKYBjb46UFTi/Y6ZikVl6PBGOS6lYQQ==","_resolved":"/tmp/95219bd59e9b99b1d4d23ef4a05bfb67/armandabric-pdf-snapshot-matcher-1.1.0.tgz","_from":"file:armandabric-pdf-snapshot-matcher-1.1.0.tgz","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-2kzW5P5A8JYG6idy6OcwsOFuXC0ZWU1iTdqplJAZUsmzoG5Ya8m5CaVoKYBjb46UFTi/Y6ZikVl6PBGOS6lYQQ==","shasum":"aa26e4f59df4c8d8e883f30edc4848854b423719","tarball":"https://registry.npmjs.org/@armandabric/pdf-snapshot-matcher/-/pdf-snapshot-matcher-1.1.0.tgz","fileCount":22,"unpackedSize":79761,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICZX34A+hyWY6TsVAfuodJXUYUHtEW3XOokgYLAI0X7eAiBK1u6+cKY5vC7thJyUjYu6ibdo2khoHx3KvMGnrTIJvw=="}]},"_npmUser":{"name":"spy-seth","email":"armand@forgebinaire.net"},"directories":{},"maintainers":[{"name":"spy-seth","email":"armand@forgebinaire.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pdf-snapshot-matcher_1.1.0_1689684267630_0.976354403053642"},"_hasShrinkwrap":false},"1.1.1":{"name":"@armandabric/pdf-snapshot-matcher","version":"1.1.1","description":"PDF snapshot matcher","author":{"name":"Benoit TRAVERS"},"license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/armandabric/pdf-snapshot.git"},"keywords":["test","jest","expect","matcher","vitest","snapshot","pdf","visual testing"],"dependencies":{"@trpc/client":"10.0.0-rc.6","@trpc/server":"10.0.0-rc.6","dedent":"^0.7.0","lodash":"^4.17.21","rimraf":"^3.0.2"},"devDependencies":{"@types/dedent":"^0.7.0","@types/jest":"^29.2.2","@types/lodash":"^4.14.188","@types/node":"^18.11.9","@types/rimraf":"^3.0.2","expect":"^29.5.0","jest":"29.3.0","testcontainers":"^9.0.0","ts-jest":"^29.0.3","typescript":"^4.8.4","@armandabric/pdf-snapshot-service":"^0.0.1"},"peerDependencies":{"expect":">= 29"},"scripts":{"prebuild":"rimraf dist","build":"tsc -p tsconfig.build.json","test":"jest","test:debug":"DEBUG=testcontainers* jest"},"bugs":{"url":"https://github.com/armandabric/pdf-snapshot/issues"},"homepage":"https://github.com/armandabric/pdf-snapshot#readme","_id":"@armandabric/pdf-snapshot-matcher@1.1.1","_integrity":"sha512-tIse57/2soeReQspIhKy613uSTssr7d1dm5CYpDiEIEn7qTs5Udz/45MBuapMHgWUIBRbblvqpZBFmHRjtZnLA==","_resolved":"/tmp/1c931f7a5be4546834d4b90c1ca5c8d8/armandabric-pdf-snapshot-matcher-1.1.1.tgz","_from":"file:armandabric-pdf-snapshot-matcher-1.1.1.tgz","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-tIse57/2soeReQspIhKy613uSTssr7d1dm5CYpDiEIEn7qTs5Udz/45MBuapMHgWUIBRbblvqpZBFmHRjtZnLA==","shasum":"9548237909a8ea4d036930ff139cf99ba411b614","tarball":"https://registry.npmjs.org/@armandabric/pdf-snapshot-matcher/-/pdf-snapshot-matcher-1.1.1.tgz","fileCount":22,"unpackedSize":79761,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCg5P0Lil0USrrAbzNC8y6C4unCmZz1b7pM1kqRceVu3wIgEdsG2eHS2esn1+FKg0DoKtu/mHyMaqUXyezyeUrO7QY="}]},"_npmUser":{"name":"spy-seth","email":"armand@forgebinaire.net"},"directories":{},"maintainers":[{"name":"spy-seth","email":"armand@forgebinaire.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pdf-snapshot-matcher_1.1.1_1689684645815_0.7948429507174508"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-27T14:50:46.541Z","1.0.0":"2023-06-27T14:50:46.908Z","modified":"2023-07-18T12:50:46.197Z","1.1.0":"2023-07-18T12:44:27.820Z","1.1.1":"2023-07-18T12:50:46.027Z"},"maintainers":[{"name":"spy-seth","email":"armand@forgebinaire.net"}],"description":"PDF snapshot matcher","homepage":"https://github.com/armandabric/pdf-snapshot#readme","keywords":["test","jest","expect","matcher","vitest","snapshot","pdf","visual testing"],"repository":{"type":"git","url":"git+https://github.com/armandabric/pdf-snapshot.git"},"author":{"name":"Benoit TRAVERS"},"bugs":{"url":"https://github.com/armandabric/pdf-snapshot/issues"},"license":"MIT","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/@armandbaric/pdf-snapshot-jest?color=g&label=version&logo=npm)\n![Docker Image Version (latest semver)](https://img.shields.io/docker/v/btravers/pdf-snapshot?color=g&logo=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\n```sh\ndocker pull armandabric/pdf-snapshot\n```\n\nThen install Jest matcher in the dev dependencies of your project.\n\n```sh\nnpm install --save-dev @armandabric/pdf-snapshot-matcher\n```\n\nPlease note that Jest 28 is a peerDependency.\n\nDeclare `toMatchPdfSnapshot` matcher in your Jest configuration.\n\n```ts\nimport { toMatchPdfSnapshot } from '@armandabric/pdf-snapshot-matcher';\n\nexpect.extend({ toMatchPdfSnapshot });\n```\n\n<!-- If you are using **Typescript** add `import('@armandabric/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\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', () => {\n  it('should match', () => 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","readmeFilename":"README.md"}