From 393b7c3648f8708bcf3d778f8a156daa3a1764ee Mon Sep 17 00:00:00 2001 From: maciej-ka Date: Sun, 6 Aug 2023 17:03:00 +0200 Subject: [PATCH] docs: update section about tests --- CONTRIBUTING.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3e2b7b81e..1716d7697 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -99,14 +99,28 @@ npx parcel serve index.html And visit http://localhost:1234 -## Add tests for your changes +## Tests -As of now, we have very less tests, and from now on, would like to pay extra attention to it. It would be great if the changes you did could be tested somehow. Our tests live inside the `tests` directory, and they can be run with the following command: +Apexcharts comes with unit tests and integration tests. Integration tests are based on viewing sample projects in a test browser, taking screenshots, and comparing them with previously captured screenshots to detect differences. To run them all, use: -```sh +```bash npm run test ``` +If this command ends with an error `Error: Unable to launch browser, error message: Chromium revision is not downloaded.` then calling puppeteer install may solve the problem: + +```bash +node node_modules/puppeteer/install.js +``` + +E2e tests will likely fail due to minor differences in OS and the browser version used to take screenshots. To address this, before working on a feature, recapture screenshots using this command: + +```bash +npm run e2e:update +``` + +This way, when later working on a feature or fix, `npm run test` command will detect only screenshots affected by changes done. Please avoid sending locally generated screenshots in PR, by excluding `tests/e2e/snapshots` folder from commit. + ## Send your changes back to us! :revolving_hearts: We'd love for you to contribute your changes back to `apexcharts.js`! To do that, it would be great if you could commit your changes to a separate feature branch and open a Pull Request for those changes.