Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation on how to do unit testing #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down