pdftest v0.3.0
pdftest
Visual PDF comparison tool.
Usage
- Add pdftestto your project usingnpm install --save-dev pdftest.
- Run the PDF file server using pdftest serve(optionally specifying a port and root folder, e.g.pdftest serve 3000 ./path/to/pdfs/).
- Import or require pdftestin your test files, making sure your tests are being run in a browser (e.g. viakarma).
- Connect pdftestto the server usingpdftest.client.api.connect(e.g.pdftest.client.api.connect('http://localhost:3000')).
- Use the comparison functions pdftest.client.compareand/orpdftest.client.compareToSnapshotto compare PDFs.
Note: When using the main browser dist (pdftest.client.min.js), you will have access to only the client methods, which will be exposed directly on the pdftest exposed variable.
E.g. in the browser, you should invoke pdftest.api.connect and pdftest.compare, rather than pdftest.client.api.connect / pdftest.client.compare.
Running the PDF server with tests
In most use cases you will need to start the pdftest server before running your tests, and end it when the tests are finished. There are several patterns to accomplish this:
- start-server-and-test(recommended):- Install - start-server-and-testas a dev dependency (- npm i -D start-server-and-test), then use in your npm scripts:- "test:serve": "pdftest serve 3000", "test:run": "karma start", "test": "start-server-and-test test:serve http://localhost:3000 test:run",
- pdftest startand- pdftest stop:- This option is built-in and requires no extra dependencies - its main disadvantage is that it will not automatically stop the server if something goes wrong. Active processes are tracked in a - data.jsonfile, which- pdftest stopreferences to kill the process. In rare cases this approach could result in "orphaned" background processes.- To use it in your npm scripts: - "test": pdftest start 3000 && karma start && pdftest stop 3000",
- npm-run-alland- wait-on:- Install - npm-run-alland- wait-onas dev dependencies (- npm i -D npm-run-all wait-on), then use in your npm scripts:- "test:serve": "pdftest serve 3000", "test:run": "wait-on http://localhost:3000 && karma start", "test": "npm-run-all --parallel --race test:serve test:run",
- Using - &(not recommended):- You may use &to run the server and tests simultaneously, e.g.pdftest serve 3000 & karma start
- This requires no additional dependencies, however:- It does not guarantee the server is running before tests start
- It does not end the server process when tests finish
- It is not supported on Windows
 
 
- You may use 
For more info, see the discussion of options in the Cypress documentation.
Release process
npm run stage-release [major/minor/patch]: Bumps the version and creates a release branch to prepare the new release.
npm run release [tagmessage]: Builds the release, tags it, and merges it back into master.
npm publish: Publishes the current version to npm.
Make sure to define .env with environment variables used by @sortpark/build-tools - see .env.sample for example values.