Please ensure that any contribution contains code that passes linting and tests (unit and rendering ones), and that is correctly formatted.
To run the demo app:
$ npm run demo
The app is accessible on http://localhost:8080.
All following checks are mandatory for a contribution to be accepted. Thanks!
Code linting is done using ESLint. To run it:
$ npm run lint
The library is written in Javascript with JSDoc annotations, which allows typechecking with the Typescript compiler. To run typechecking:
$ npm run typecheck
Code formatting is done using Prettier. To re-format all code, run:
$ npm run format
Unit tests are written using Jest and are located in the test/unit
folder.
To run them:
$ npm run test:unit
Rendering tests are also available for testing the output of a given JSON print spec. They use pixelmatch to determine whether the received image is identical to the expected one for each print spec.
Test cases are located in the test/rendering/cases
folder, where each folder corresponds to one test case. Folders contain:
- a
spec.json
file - an
expected.png
file - after tests have been run, a
received.png
file is also present and can be used to check differences with the expected result
To run the rendering tests:
$ npm run test:rendering
In case of a new or updated rendering test, the expected image can be generated by running:
$ npm run test:rendering -- --fix
This will in essence copy the received.png
file to the expected.png
one for each rendering test.
This command will logically always succeed.
Also running the following command will start the tests in interactive mode, i.e. without headless mode and with the browser left running for 30mn:
$ npm run test:rendering -- --interactive