Commit d0e4aa83 authored by Lynn's avatar Lynn Committed by GitHub

fix: add jest coverage config to package.json (#3896)

* fix: add jest coverage config to package.json

* fix: add running test instructions to CONTRIBUTING.md

* fix: respond to zzmp comments

* fix: lower test thresholds
Co-authored-by: default avatarLynn Yu <lynn.yu@uniswap.org>
parent b17a38d9
# Contributing # Contributing
Thank you for your interest in contributing to the Uniswap interface! 🦄 Thank you for your interest in contributing to the Uniswap interface! 🦄
...@@ -15,10 +14,20 @@ Thank you for your interest in contributing to the Uniswap interface! 🦄 ...@@ -15,10 +14,20 @@ Thank you for your interest in contributing to the Uniswap interface! 🦄
1. `yarn install` 1. `yarn install`
1. `yarn build` 1. `yarn build`
## Running unit tests
- Run unit tests: `yarn test`
- Run unit tests and show test coverage info for all tests: `yarn test --watchAll`
## Running cypress integration tests
1. `yarn build:e2e`
2. `yarn test:e2e`
## Engineering standards ## Engineering standards
Code merged into the `main` branch of this repository should adhere to high standards of correctness and maintainability. Code merged into the `main` branch of this repository should adhere to high standards of correctness and maintainability.
Use your best judgment when applying these standards. If code is in the critical path, will be frequently visited, or Use your best judgment when applying these standards. If code is in the critical path, will be frequently visited, or
makes large architectural changes, consider following all the standards. makes large architectural changes, consider following all the standards.
- Have at least one engineer approve of large code refactorings - Have at least one engineer approve of large code refactorings
...@@ -39,7 +48,7 @@ The following points should help guide your development: ...@@ -39,7 +48,7 @@ The following points should help guide your development:
- Avoid adding steps to the development/build processes - Avoid adding steps to the development/build processes
- The build must be deterministic, i.e. a particular commit hash always produces the same build - The build must be deterministic, i.e. a particular commit hash always produces the same build
- Decentralization: anyone can run the interface - Decentralization: anyone can run the interface
- An Ethereum node should be the only critical dependency - An Ethereum node should be the only critical dependency
- All other external dependencies should only enhance the UX ([graceful degradation](https://developer.mozilla.org/en-US/docs/Glossary/Graceful_degradation)) - All other external dependencies should only enhance the UX ([graceful degradation](https://developer.mozilla.org/en-US/docs/Glossary/Graceful_degradation))
- Accessibility: anyone can use the interface - Accessibility: anyone can use the interface
- The interface should be responsive, small and also run well on low performance devices (majority of swaps on mobile!) - The interface should be responsive, small and also run well on low performance devices (majority of swaps on mobile!)
...@@ -48,14 +57,14 @@ The following points should help guide your development: ...@@ -48,14 +57,14 @@ The following points should help guide your development:
Releases are cut automatically from the `main` branch Monday-Thursday in the morning according to the [release workflow](./.github/workflows/release.yaml). Releases are cut automatically from the `main` branch Monday-Thursday in the morning according to the [release workflow](./.github/workflows/release.yaml).
Fix pull requests should be merged whenever ready and tested. Fix pull requests should be merged whenever ready and tested.
If a fix is urgently needed in production, releases can be manually triggered on [GitHub](https://github.com/Uniswap/uniswap-interface/actions/workflows/release.yaml) If a fix is urgently needed in production, releases can be manually triggered on [GitHub](https://github.com/Uniswap/uniswap-interface/actions/workflows/release.yaml)
after the fix is merged into `main`. after the fix is merged into `main`.
Features should not be merged into `main` until they are ready for users. Features should not be merged into `main` until they are ready for users.
When building larger features or collaborating with other developers, create a new branch from `main` to track its development. When building larger features or collaborating with other developers, create a new branch from `main` to track its development.
Use the automatic Vercel preview for sharing the feature to collect feedback. Use the automatic Vercel preview for sharing the feature to collect feedback.
When the feature is ready for review, create a new pull request from the feature branch into `main` and request reviews from When the feature is ready for review, create a new pull request from the feature branch into `main` and request reviews from
the appropriate UX reviewers (PMs or designers). the appropriate UX reviewers (PMs or designers).
## Finding a first issue ## Finding a first issue
...@@ -65,7 +74,7 @@ Start with issues with the label ...@@ -65,7 +74,7 @@ Start with issues with the label
# Translations # Translations
Uniswap uses [Crowdin](https://crowdin.com/project/uniswap-interface) for managing translations. Uniswap uses [Crowdin](https://crowdin.com/project/uniswap-interface) for managing translations.
[This workflow](./.github/workflows/crowdin.yaml) uploads new strings for translation to the Crowdin project whenever code using the [lingui translation macros](https://lingui.js.org/ref/macro.html) is merged into `main`. [This workflow](./.github/workflows/crowdin.yaml) uploads new strings for translation to the Crowdin project whenever code using the [lingui translation macros](https://lingui.js.org/ref/macro.html) is merged into `main`.
Every hour, translations are synced back down from Crowdin to the repository in [this other workflow](./.github/workflows/crowdin-sync.yaml). Every hour, translations are synced back down from Crowdin to the repository in [this other workflow](./.github/workflows/crowdin-sync.yaml).
......
...@@ -16,11 +16,32 @@ ...@@ -16,11 +16,32 @@
"prepare": "yarn contracts:compile && yarn graphql:generate && yarn i18n:compile", "prepare": "yarn contracts:compile && yarn graphql:generate && yarn i18n:compile",
"start": "react-scripts start", "start": "react-scripts start",
"build": "react-scripts build", "build": "react-scripts build",
"test": "react-scripts test", "test": "react-scripts test --coverage",
"build:e2e": "env-cmd -f .env yarn build", "build:e2e": "env-cmd -f .env yarn build",
"test:e2e": "start-server-and-test 'serve build -l 3000' http://localhost:3000 'cypress open'", "test:e2e": "start-server-and-test 'serve build -l 3000' http://localhost:3000 'cypress open'",
"test:e2e:ci": "start-server-and-test 'serve build -l 3000' http://localhost:3000 'cypress run --record'" "test:e2e:ci": "start-server-and-test 'serve build -l 3000' http://localhost:3000 'cypress run --record'"
}, },
"jest": {
"collectCoverageFrom":
[
"src/components/**/*.ts*",
"src/hooks/**/*.ts*",
"src/lib/hooks/**/*.ts*",
"src/lib/state/**/*.ts*",
"src/lib/utils/**/*.ts*",
"src/pages/**/*.ts*",
"src/state/**/*.ts*",
"src/utils/**/*.ts*"
],
"coverageThreshold": {
"global": {
"branches": 4,
"functions": 6,
"lines": 9,
"statements": 9
}
}
},
"browserslist": { "browserslist": {
"production": [ "production": [
">0.2%", ">0.2%",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment