mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-06 07:06:11 +00:00
feat: e2e snapshot tests (#2338)
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect --> # Summary This PR adds E2E tests based on view screenshots done via `react-native-view-shot`. It only works with devices that have their [pixel ratio](https://reactnative.dev/docs/pixelratio) equal `3`. If you want to use device with different pixel ratio, you need to adjust it in `e2e/generateReferences.ts` viewport and regenerate reference images (see below). Steps to run tests: - Run Metro server for example app via `yarn start` in example app's directory - Run `example` app on platform of your choice (currently only Android & iOS are supported) via `yarn android` or `yarn ios` in example app's directory - Run `yarn e2e` in project's root directory to start Jest server - Select `E2E` tab in example app - Wait for tests to finish - You can see test results, as well as diffs (actual rendered svg vs reference image) in `e2e/diffs` directory Steps to add new test cases: - Put SVG of your choice to `e2e/cases` directory - Run `yarn generateE2eRefrences`, this will open headless chrome browser via `puppeteer` and snapshot all rendered SVGs to .png files and later use them as reference in tests - You should see new .png files in `e2e/references` - When you run E2E tests again, it will use new test case(s) you've added ## Test Plan https://github.com/software-mansion/react-native-svg/assets/41289688/24ee5447-ce9a-43b6-9dde-76229d25a30a https://github.com/software-mansion/react-native-svg/assets/41289688/71d1873f-8155-4494-80bd-e4c1fa72a065 ### What's required for testing (prerequisites)? See Summary ### What are the steps to reproduce (after prerequisites)? See Summary ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ✅ | | Android | ✅ | | Web | ❌ | ## Checklist <!-- Check completed item, when applicable, via: [X] --> - [X] I have tested this on a device and a simulator - [x] I added documentation in `README.md` - [X] I updated the typed files (typescript) - [X] I added a test for the API in the `__tests__` folder --------- Co-authored-by: bohdanprog <bohdan.artiukhov@swmansion.com> Co-authored-by: Jakub Grzywacz <jakub.grzywacz@swmansion.com>
This commit is contained in:
committed by
GitHub
parent
53ba6f2413
commit
a089cc2efc
14
package.json
14
package.json
@@ -58,6 +58,8 @@
|
||||
"release": "npm login && release-it",
|
||||
"test": "npm run lint && npm run tsc",
|
||||
"tsc": "tsc --noEmit",
|
||||
"e2e": "jest e2e",
|
||||
"generateE2eReferences": "ts-node e2e/generateReferences.ts",
|
||||
"check-archs-consistency": "node ./scripts/codegen-check-consistency.js",
|
||||
"sync-archs": "node ./scripts/codegen-sync-archs.js"
|
||||
},
|
||||
@@ -78,7 +80,10 @@
|
||||
"@types/css-tree": "^1.0.3",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@types/node": "*",
|
||||
"@types/pixelmatch": "^5.2.0",
|
||||
"@types/pngjs": "^6.0.5",
|
||||
"@types/react": "^18.2.18",
|
||||
"@types/ws": "^8.5.10",
|
||||
"@typescript-eslint/eslint-plugin": "^5.11.0",
|
||||
"@typescript-eslint/parser": "^5.11.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
@@ -96,18 +101,23 @@
|
||||
"eslint-plugin-standard": "^5.0.0",
|
||||
"husky": "^8.0.1",
|
||||
"jest": "^28.1.0",
|
||||
"jest-html-reporters": "^3.1.7",
|
||||
"lint-staged": "^13.0.3",
|
||||
"peggy": "4.0.3",
|
||||
"pegjs": "^0.10.0",
|
||||
"pixelmatch": "5.3.0",
|
||||
"pngjs": "^7.0.0",
|
||||
"prettier": "3.0.1",
|
||||
"puppeteer": "^22.12.1",
|
||||
"react": "^18.2.0",
|
||||
"react-native": "^0.72.3",
|
||||
"react-native-builder-bob": "^0.20.4",
|
||||
"react-native-windows": "^0.72.4",
|
||||
"react-test-renderer": "^18.2.0",
|
||||
"release-it": "^14.12.5",
|
||||
"ts-node": "^10.8.0",
|
||||
"typescript": "^5.1.6"
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.1.6",
|
||||
"ws": "^8.18.0"
|
||||
},
|
||||
"lint-staged": {
|
||||
"{src,Example}/**/*.{js,ts,tsx}": "yarn format-js",
|
||||
|
||||
Reference in New Issue
Block a user