From e42511c6ecdf782256b1f76b97ce12baec39d2a5 Mon Sep 17 00:00:00 2001 From: Elias Rodelo Date: Fri, 7 Dec 2018 14:44:58 -0500 Subject: [PATCH] Added documentation on how to do unit testing --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 71dbb28..1b29dd9 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,22 @@ eventListeners=[ ] ``` +## Unit Testing + +This is based on what tool or framework are you using for testing, this configuration is for Jest, the one that is working out-of-the-box with [CRA](https://github.com/facebook/create-react-app). In order to properly work you must: + +* Install [`jest-canvas-mock` library](https://github.com/hustcc/jest-canvas-mock) +* Go to your `setupTests.js` file, in the top of your file do as follows: +```javascript +... +import 'jest-canvas-mock'; + +... +``` +* Once you imported the file, restart Jest on your console and you're ready to go + +For other frameworks besides Jest, you have to check if it uses JSDom or what JavaScript implementation is using, and check if that implementation mimics the `canvas` element, if not, you should do the same, probably. + ## Related Projects * [Bodymovin](https://github.com/bodymovin/bodymovin) react-lottie is a wrapper of bodymovin