You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Run the commands in the [Building](#building) section
50
-
- Build the Android binaries with `yarn build-skia-android`
51
-
- Build the NPM package with `yarn build-npm`
52
-
53
-
Publish the NPM package manually. The output is found in the `dist` folder.
54
-
55
-
- Install Cocoapods in the example/ios folder `cd example/ios && pod install && cd ..`
56
-
57
19
## Contributing
58
20
59
-
When making contributions to the project, an important part is testing.
60
-
In the `package` folder, we have several scripts set up to help you maintain the quality of the codebase and test your changes:
61
-
62
-
-`yarn lint` — Lints the code for potential errors and to ensure consistency with our coding standards.
63
-
-`yarn tsc` — Runs the TypeScript compiler to check for typing issues.
64
-
-`yarn test` — Executes the unit tests to ensure existing features work as expected after changes.
65
-
-`yarn e2e` — Runs end-to-end tests. For these tests to run properly, you need to have the example app running. Use `yarn ios` or `yarn android` in the `example` folder and navigate to the Tests screen within the app.
66
-
67
-
## Running End-to-End Tests
68
-
69
-
To ensure the best reliability, we encourage running end-to-end tests before submitting your changes:
70
-
71
-
1. Start the example app:
72
-
```sh
73
-
cd example
74
-
yarn ios # or yarn android for Android testing
75
-
```
76
-
77
-
Once the app is open in your simulator or device, press the "Tests" item at the bottom of the list.
78
-
79
-
2. With the example app running and the Tests screen open, run the following command in the `package` folder:
80
-
```sh
81
-
yarn e2e
82
-
```
83
-
84
-
This will run through the automated tests and verify that your changes have not introduced any regressions.
85
-
You can also run a particular using the following command:
86
-
```sh
87
-
E2E=true yarn test -i e2e/Colors
88
-
```
89
-
90
-
### Writing End-to-End Tests
91
-
92
-
Contributing end-to-end tests to React Native Skia is extremely useful. Below you'll find guidelines for writing tests using the `eval`, `draw`, and `drawOffscreen` commands.
93
-
94
-
e2e tests are located in the `package/__tests__/e2e/` directory. You can create a file there or add a new test to an existing file depending on what is most sensible.
95
-
When looking to contribute a new test, you can refer to existing tests to see how these can be built.
96
-
The `eval` command is used to test Skia's imperative API. It requires a pure function that invokes Skia operations and returns a serialized result.
Both the `eval` and `draw` commands require a function that will be executed in an isolated context, so the functions must be pure (without external dependencies) and serializable. You can use the second parameter to provide extra data to that function.
Finally, you can use `drawOffscreen` to receive a canvas object as parameter. You will also get the resulting image:
141
-
142
-
```tsx
143
-
it("Should draw cyan", async () => {
144
-
const image =awaitsurface.drawOffscreen(
145
-
(Skia, canvas, { size }) => {
146
-
canvas.drawColor(Skia.Color("cyan"));
147
-
}
148
-
);
149
-
checkImage(image, "snapshots/cyan.png");
150
-
});
151
-
```
152
-
153
-
Again, since `eval`, `draw`, and `drawOffscreen` serialize the function's content, avoid any external dependencies that can't be serialized.
21
+
For detailed information on library development, building, testing, and contributing guidelines, please see [CONTRIBUTING.md](packages/skia/CONTRIBUTING.md).
0 commit comments