| App widgets | Integration or E2E with testing-library or QA Wolf | End users | Create user form. Reset password form. | Less reusable code with more complex environment setup and dependencies. Depending on the case, can be done with integration or E2E. For integration, mock at the backend level; don't mock other UI systems. For E2E, don't mock other systems except for common network error states. |
| User journeys | E2E with QA Wolf | End users | Filtering a host by software. Creating a team as admin. | Full business flows. Little to no mocking of systems, except for common network error states. |
| N/A | Manual | N/A | // TODO | Manual testing can be used for all types of code. Examples would be for one-offs or states that would require extremely difficult testing setups. |
#### Manual testing
There will always be a space for manual testing. We use it for testing states that do not
occur very often in the application or are not worth the effort to test for unlikely edge cases.
#### Static analysis
This includes typing and linting to quickly ensure proper typings of data flowing through the
application, and that we are following coding conventions and styling rules. This gives us a first
line of defense against writing buggy code.
#### Unit testing
We unit test smaller reusable components that have little to no dependencies within them. These
components are primarily parametric-based and require no or minimal mocking to be tested
effectively. They tend to be small building blocks of our application (e.g., reusable UI components,
common utilities, reusable hooks). With unit testing, the end users tend to be other developers, so
we ensure these components work as expected when used as building blocks.
##### Shared utilities testing
We can test utility functions purely with Jest and don't have to worry about rendering components with
react-testing-library. Only Jest is needed with minimal mocking.
[View the full url utility testing source](https://github.com/fleetdm/fleet/blob/main/frontend/utilities/url/url.tests.ts).
```tsx
import { buildQueryStringFromParams } from ".";
describe("url utilities", () => {
it("creates a query string from a params object", () => {
We use integration testing to strike a balance between speed and expense to write our tests. We use
them to test multiple reusable components that come together into less reusable app widgets. We also
try to use minimal mocking, but we can mock at the backend level if required.
##### App widget testing
This layer of tests is great for testing difficult to obtain states and edge cases as the test setup
is simpler than E2E tests. We highly utilize react-testing-library to interface with these components.
[View the full ResetPasswordForm app widget testing source](https://github.com/fleetdm/fleet/blob/main/frontend/components/forms/ResetPasswordForm/ResetPasswordForm.tests.jsx).
```tsx
import React from "react";
import { render, screen } from "@testing-library/react";
The code is deployed and tested once daily on the testing instance. However, development may necessitate running E2E tests on demand. To run E2E tests live on a branch such as the `main` branch, developers can navigate to [Deploy Cloud Environments](https://github.com/fleetdm/confidential/actions/workflows/cloud-deploy.yml) in our [/confidential](https://github.com/fleetdm/confidential) repo's Actions and select "Run workflow".