-
Notifications
You must be signed in to change notification settings - Fork 4
Testing
Testing is an essential part of engineering best practices.
It ensures reliability, prevents regressions, and builds confidence in your code before it reaches production or other team members.
This page outlines the core testing expectations for practicum projects, including unit tests, integration tests, UI/snapshot tests, and when testing is required.
Unit tests focus on validating the smallest pieces of code:
functions, utilities, classes, components, logic blocks.
- Validate expected outputs
- Catch edge cases
- Ensure functions behave predictably
- Prevent regressions when code changes
Unit tests usually follow this pattern:
describe("functionName", () => {
it("should do something expected", () => {
// Arrange
const input = ...
// Act
const result = functionName(input)
// Assert
expect(result).toBe(...)
})
})- One test suite (
describe) per function or module - One behavior tested per
itblock - Use clear naming:
βshould return X when Y occursβ - Avoid testing implementation detailsβtest outcomes
- Keep tests small and isolated
- Jest (JS/TS, React, Node)
- PyTest (Python)
- Vitest (modern JS/TS projects)
- JUnit (Java/Kotlin, Android)
(Tools depend on course track β check your project requirements.)
View Integration Testing Guidelines
Integration tests validate how multiple modules work together.
They cover real-world flows rather than individual functions.
- API request + data handling workflows
- Component interaction (e.g., button triggers navigation)
- Database + service logic
- Multi-step operations (login β fetch data β render UI)
- Test the full flow, not just pieces
- Use mock services when needed (e.g., fake APIs)
- Avoid overly complex test setups
- Name tests according to user behavior:
βlogs in and loads profile dataβ
it("logs in and fetches user profile", async () => {
mockApi.post.mockResolvedValue({ token: "123" })
mockApi.get.mockResolvedValue({ name: "Alice" })
await login("alice", "password")
const profile = await loadProfile()
expect(profile.name).toBe("Alice")
})- Jest + React Testing Library
- Playwright or Cypress (advanced UI integration)
- PyTest (Python backends)
- Espresso (Android)
View UI / Snapshot Testing
Used for:
- React components
- Expo screens
- Small UI units that should remain visually identical
Snapshot example:
it("renders correctly", () => {
const tree = render(<HomeScreen />).toJSON()
expect(tree).toMatchSnapshot()
})- Visual regression testing
- Accessibility testing
- End-to-end UI flows
- Platform-specific handling (iOS vs Android)
- Jest Snapshot Testing
- React Native Testing Library
- Playwright Visual Regression
- Detox (native mobile)
This section will be expanded once the practicum finalizes its UI testing stack.
View Testing Requirements
Testing requirements vary depending on the project, class, and team expectations.
Below is the general rule for the practicum.
- Creating or modifying core business logic
- Adding utilities that will be reused across the project
- Fixing a bug (add a test to prevent regression)
- Working in modules that already have tests
- Writing complex data transformations
- Building login, authentication, or security-related features
- Adding new React components
- Writing helper functions
- Adding new API request flows
- Doing refactors
- Modifying UI styling only (CSS/Tailwind)
- Updating README or documentation
- Changing small layout components
- Temporary prototypes (unless used in production)
- Certain projects may enforce stricter test coverage
- Some repos may include a βminimum coverageβ threshold
Always check your projectβs README and ask your PM or Lead Engineer if unsure.
Home β’ New Student Onboarding β’ Guides β’ Projects β’ Code of Conduct β’ FAQ
Last updated: 12/7/2025