Thank you for helping out with react-native-svg! We'd like to make contributions as pleasant as possible, so here's a small guide of how we see it. Happy to hear your feedback about anything, so please let us know.
- Fork this repository
- Clone your fork
- Make a branch for your feature or bug fix (i.e.
git checkout -b added-getfoobar
) - Work your magic
- Execute
yarn link
when done.
Add test example in tests-example
concerning your change following the convention of TestX.tsx
where X
is your PR number.
We use typescript
for type checks, eslint
with prettier
for linting/formatting. All tests are run by github
actions for all opened pull requests.
yarn test
: Run all tests, except for e2e (see note below).yarn lint
: Runeslint
check.yarn tsc
: Runtypescript
check.yarn jest
: Runjest
type check.yarn e2e
: Run E2E tests (see section below)
Warning
Reference images in this repository are generated with pixel ratio = 3
.
Make sure to run tests on a device that also has pixel ratio equal 3. Otherwise tests will fail.
In order to use device with different pixel ratio, adjust it in e2e/generateRefereces.ts
viewport and regenerate
references.
- Navigate to the example application's directory and initiate the Metro server using the yarn start command.
- To run the example application on your preferred platform (note: currently only Android and iOS are supported),
execute the command
yarn android
oryarn ios
within the example app's directory. - Start the Jest server by running
yarn e2e
in the project's root directory. - In the example application, select the E2E tab.
- Allow the tests to complete.
- The test results, along with any differences (i.e. the actual rendered svg versus the reference image), can be viewed
in the
e2e/diffs
directory.
- Put an SVG file of your selection into the
e2e/cases
directory. - Execute
yarn generateE2eRefrences
. This action launches a headless Chrome browser via Puppeteer, capturing snapshots of all rendered SVGs as .png files. These files will serve as a reference during testing. - Check the
e2e/references
directory to observe newly created .png files. - When you rerun the E2E tests, the new test case(s) you've added will be incorporated.
When you're sending a pull request:
- Communication is a key. If you want fix/add something, please consider either opening a new issue or finding an existing one so we can further discuss it.
- We prefer small pull requests focused on one change, as those are easier to test/check.
- Please make sure that all tests are passing on your local machine.
- Follow the template when opening a PR.
All PRs are merged into the main
branch and released with release-it
.
Most notably prefixes you'll see:
- fix: Bug fixes
- feat: New feature implemented
- chore: Changes that are not affecting end user (CI config changes, scripts, "grunt work")
- docs: Documentation changes.
- perf: A code change that improves performance.
- refactor: A code change that neither fixes a bug nor adds a feature.
- test: Adding missing tests or correcting existing tests.
We use release-it to release new versions of library from main
branch.
You can report issues on our bug tracker. Please search for existing issues and follow the issue template when opening one.
By contributing to React Native Svg, you agree that your contributions will be licensed under the MIT license.