Skip to content

Commit

Permalink
fix: extend mocking rules for ui integrationt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptotavares committed Sep 30, 2024
1 parent 2ccc5b3 commit 216c33e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/testing/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ At MetaMask, we are committed to delivering high-quality software. A key aspect

## What are unit tests?

Unit testing is a conceptually vague practice, as there is no consensus on how they should be written and what they should test. But in general, [as outlined by Martin Fowler](https://martinfowler.com/articles/2021-test-shapes.html), there are two common approaches: solitary unit tests and sociable unit tests. At MetaMask, we employ both of these types of unit tests (see [discussion on the use cases of each type](https://github.com/MetaMask/core/pull/3827#discussion_r1469377179))
Unit testing is a conceptually vague practice, as there is no consensus on how they should be written and what they should test. But in general, [as outlined by Martin Fowler](https://martinfowler.com/articles/2021-test-shapes.html), there are two common approaches: solitary unit tests and sociable unit tests. At MetaMask, we employ both of these types of unit tests (see [discussion on the use cases of each type](https://github.com/MetaMask/core/pull/3827#discussion_r1469377179)).
Unit tests examine individual components or functions in isolation or within their immediate context. At MetaMask we encourage a flexible approach to unit testing, recognizing the spectrum between sociable and solitary unit tests.

### When to write unit tests?
Expand Down
2 changes: 1 addition & 1 deletion docs/testing/ui-integration-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Refrain from using snapshot testing in UI integration tests. They tend to be les

## Don't Mock UI Components

Keep mocking to minimum. Ideally only the background connection (MetaMask Extension), or any network request (fired from the UI) should be mocked.
Keep mocking to minimum. Ideally only the background connection (MetaMask Extension), or any network request (fired from the UI) should be mocked. Avoid mocking any UI components or hooks. For mocking the background connection we can use jest, for mocking network requests we can use `nock` (or `msw`).

0 comments on commit 216c33e

Please sign in to comment.