Skip to content

Latest commit

 

History

History
74 lines (53 loc) · 2.09 KB

CONTRIBUTING.md

File metadata and controls

74 lines (53 loc) · 2.09 KB

Contribution guidelines

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!

Linting

Code linting is done using ESLint. To run it:

$ npm run lint

Type checking

The library is written in Javascript with JSDoc annotations, which allows typechecking with the Typescript compiler. To run typechecking:

$ npm run typecheck

Formatting

Code formatting is done using Prettier. To re-format all code, run:

$ npm run format

Testing

Unit tests

Unit tests are written using Jest and are located in the test/unit folder.

To run them:

$ npm run test:unit

Rendering tests

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