- Getting Set up
- Building Samples and Packages
- Running a Sample or Storybook
- Testing your changes
- Writing unit tests
- Submitting a PR
- Having your changes published
Our unit tests are written using Jest.
-
All unit tests must be in a
.test.ts
or.test.tsx
file - jest will automatically pick up these files and run them. -
Unit tests must be well named and test only one thing per test.
-
Unit tests must follow the Arrange, Act, Assert pattern, e.g.
test("addOne function should add one to a given number", () => { // Arrange const givenNumber = 5; // Act const result = addOne(givenNumber); // Assert expect(result).toEqual(6); });
- This ensures good structure to unit tests making them easily understandable for the developer who needs to take a look at them when they do not pass.
-
UI components must have snapshot tests (see Generating new snapshots)
To run unit tests for the package or sample you are in:
rushx test # run this from the package directory
To run all unit tests for the whole repo
rush test # this can be run from anywhere
Documentation to follow.
- Next: Submitting a PR
- Previous: Testing your changes