Simpler.Grants.gov Public Wiki
Grants.govSimpler.Grants.govGitHubDiscourse
  • 👋Welcome
  • GET INVOLVED
    • Why open source?
    • How to contribute code
    • How to file issues
      • Report a bug
      • Request a feature
      • Report a security vulnerability
    • Community guidelines
      • Code of Conduct
      • Reporting and removing content
      • Incident response protocol
    • Community events
      • Fall 2024 Coding Challenge
        • Event Submissions & Winners
      • Spring 2025 Collaborative Coding Challenge
        • Event Submissions & Winners
    • Communication channels
  • Product
    • Roadmap
    • Deliverables
      • 🏁Static site soft launch
      • 🏁Static site public launch
      • 🏁GET Opportunities
      • 🏁Open source onboarding
      • 🏁Co-Design Group planning
    • Decisions
      • ADR Template
      • ADRs
        • Dedicated Forum for Simpler.Grants.gov Community
        • Recording Architecture Decisions
        • Task Runner for the CI / CD Pipeline
        • API Language
        • Use Figma for design prototyping
        • ADR: Chat
        • DB Choices
        • API Framework and Libraries
        • Back-end Code Quality Tools
        • Front-end Language
        • Communications Tooling: Wiki Platform
        • Use Mural for design diagrams and whiteboarding
        • Ticket Tracking
        • Front-end Framework
        • Front-end Code Quality Tools
        • Front-end Testing & Coverage
        • Backend API Type
        • Front-end Testing & Coverage
        • Deployment Strategy
        • Use U.S. Web Design System for components and utility classes
        • FE server rendering
        • Use NPM over Yarn Architectural Decision Records
        • U.S. Web Design System in React
        • Communications Tooling: Video Conferencing
        • Back-end Production Server
        • Communications Tooling: Analytics Platform
        • Commit and Branch Conventions and Release Workflow
        • Cloud Platform to Host the Project
        • Infrastructure as Code Tool
        • Data Replication Strategy & Tool
        • HHS Communications Site
        • Communications Tooling: Email Marketing
        • Communications Tooling: Listserv
        • Use Ethnio for design research
        • Uptime Monitoring
        • Database Migrations
        • 30k ft deliverable reporting strategy
        • Public measurement dashboard architecture
        • Method and technology for "Contact Us" CTA
        • E2E / Integration Testing Framework
        • Logging and Monitoring Platform
        • Dashboard Data Storage
        • Dashboard Data Tool
        • Search Engine
        • Document Storage
        • Document Sharing
        • Internal Wiki ADR
        • Shared Team Calendar Platform
        • Cross-Program Team Health Survey Tool
        • Adding Slack Users to SimplerGrants Slack Workspace
        • Repo organization
        • Internal knowledge management
        • Migrate Existing API Consumers
      • Infra
        • Use markdown architectural decision records
        • CI/CD interface
        • Use custom implementation of GitHub OIDC
        • Manage ECR in prod account module
        • Separate terraform backend configs into separate config files
        • Database module design
        • Provision database users with serverless function
        • Database migration architecture
        • Consolidate infra config from tfvars files into config module
        • Environment use cases
        • Production networking long term state
    • Analytics
      • Open source community metrics
      • API metrics
  • DESIGN & RESEARCH
    • Brand guidelines
      • Logo
      • Colors
      • Grid and composition
      • Typography
      • Iconography
      • Photos and illustrations
    • Content guidelines
      • Voice and tone
    • User research
      • Grants.gov archetypes
  • REFERENCES
    • Glossary
  • How to edit the wiki
Powered by GitBook
On this page
  • Context and Problem Statement
  • Decision Drivers
  • Options Considered
  • Unit Testing
  • Pros and Cons of the Options
  • Visual, Interactive & Component Testing
  • Pros and Cons of the Options
  • Decision Outcome
  • Unit Testing
  • Visual, Interactive & Component Testing

Was this helpful?

Edit on GitHub
  1. Product
  2. Decisions
  3. ADRs

Front-end Testing & Coverage

PreviousFront-end Code Quality ToolsNextBackend API Type

Last updated 28 days ago

Was this helpful?

  • Status: Active

  • Last Modified: 2023-07-18

  • Related Issue:

  • Deciders: Sammy, Lucas, Billy, Andy

  • Tags: ADR

Context and Problem Statement

Front-end testing is essential in maintaining a stable and healthy codebase, creating UI interfaces without regression, and an important part of the developer workflow.

Decision Drivers

  • Robust: Chosen testing frameworks should have features that offer diverse ways of verifying front-end codebase functionality, reducing the need for intensive manual testing

  • Well-maintained: Accessible tooling is well-maintained by owners and keeps up with current ecosystems in which it will be integrated.

  • Ease of use: Achieving high coverage should be attainable. ICs should be able to onboard with the tooling and execute in a reasonable time frame to maintain that coverage.

  • Fast: Running tests shouldn't take ages.

Options Considered

Unit Testing

  • Jest

  • Mocha

Pros and Cons of the Options

  • Pros

    • Lightweight, well-supported and documented testing solution

    • Compatible with TypeScript, Node, React

    • Snapshot capabilities to track UI changes

    • Already integrated in Next.js front-end template

    • Built-in mocking & auto-mocking

  • Cons

    • Reports that snapshot capabilities are not for complicated UIs

    • Auto-mocking reduces performance

  • Pros

    • Has integration and end-to-end testing capabilities

    • More robust in functionality, offering a wider array of capabilities and helpers

    • Test coverage reporting available

    • Well-documented and widely used in Node.js ecosystems

  • Cons

    • Not as lightweight as alternative, requiring integrating several other libraries

    • Does not support snapshot testing

    • Slower than Jest

Visual, Interactive & Component Testing

  • Storybook

  • Cypress

Pros and Cons of the Options

  • Pro

    • Build reusable UI components and pages in isolation, mocking external dependencies and business logic

    • Visually verify changes and debug on multiple device formats easily in the interface

    • Stories can be imported into Jest or other testing frameworks

    • Covers multiple testing types, including visual, interaction, component and accessibility

    • Compatible with many helpful addons to assist in building front-ends faster

    • Component testing addon uses Jest & Playwright under the hood for speed

    • Snapshot capabilities to address DOM regressions

    • Enhances collaboration between engineers and other team members such as designers

  • Cons

    • May not be compatible with all tools and eco-systems

    • Initial ramp up for a conceptually new way of developing front-ends that ICs may not be accustomed with

    • Hasn't been around as long as other testing tools

  • Pro

    • Stubbing and mocking is simple comparatively

    • Well-documented with a long history of providing reliable end-to-end and component testing

    • Allows for visual debugging

    • Robust front-end end-to-end testing

    • Interactive GUI for end-to-end and component testing

  • Cons

    • Functionality for our current use-case likely redundant with Storybook, need to maintain stories and component tests separately

    • Can be very slow to run the full test suite

    • Might easily get out of date as another tool and testing interface

    • Uses command queuing instead of familiar async await syntax like Storybook

    • Bundles many other third-party libraries

Decision Outcome

Unit Testing

Jest, because it is integrated into the Next.js template application, well-maintained, and lightweight. Importantly, documentation is thorough and helpful information for troubleshooting can be easily accessed.

Visual, Interactive & Component Testing

Storybook, because it provides an effective methodology for developing robust front-ends quickly. It is already implemented in the Next.js template application. Integration allows multiple ways to test applications, including compatibility with Jest.

In the future, if we find that Storybook doesn't meet our testing needs, we can look into integration with Cypress. However, not recommended from the start because our use-cases are covered by Storybook and there's a strong preference to not have to integrate another tool or learn another syntax.

Code coverage reporting that can be integrated into

183
Jest
Github Actions
Mocha
Storybook
Cypress