If you are unfamiliar with the workflow of contributing to github, you can refer to this this article
The development should happen in a personal fork, cloned on the local machine.
Changes should happen against:
- the
development
branch if it is about a new feature - the
main
branch if the change is a bugfix
We use Visual Studio code internally and have also included some specific settings, such as running ESLint fixes on save, as well as automatic code formatting.
If contributing from other tools such as Jetbrains Webstorm, there might be slight formatting differences which might interfere with later edits from the internal team or from other external contributors.
Before opening a pull request, run npm run lint
against your local changes to make sure the code adheres to the accepted standards within the repo.
You can also run npm run lint:fix
to apply automatic fixes to the code.
Below some guidelines regarding writing unit tests:
- Attempt to write some unit tests which verify the component in isolation and mock the external components around it
- If the component relies on many other external components which are difficult to mock, write e2e tests for it
- Try to cover both expected functionality but also verify that the code fails in expected ways
- If fixing a bug, try to first write the unit test that exposes the bug, then fix it and have a test that will make sure the specific situation will always be tested in the future
To make sure the test suite passes, run the following commands before opening a pull request:
npm run test
to run unit testsnpm run test:e2e:warm:mocked
to warm-up integration tests with mocked data, for performance purposesnpm run test:e2e
to run integration tests
Although the nominal use case looks good, the linter runs without issues, as well as the unit & e2e tests pass without any error, some unforeseen bugs may arise.
That's why, every change, however small, should be tested thoroughly with the mindset of "How can I make the code break" by testing its limits, sending unsanitized inputs, trying to extract a lot more data than needed, etc. It will help minimize the friction between the developer and the reviewer. It will also make sure the PR gets approved & deployed faster.