Skip to content

chore(testing): Consolidate individual icon tests into a single auto-discovery test #1529

Closed

Description

@rishiraj38

Current Behavior

We currently have 8 separate test files for icon components under src/__testing__/:

  • AddIcon.test.tsx
  • ApplicationIcon.test.tsx
  • BusIcon.test.tsx
  • CircleIcon.test.tsx
  • CodeIcon.test.tsx
  • PeopleIcon.test.tsx
  • ReplyIcon.test.tsx
  • TableChartIcon.test.tsx

Each file follows the exact same pattern — render the icon and assert width/height. This means:

  1. Only 8 out of 230+ icon components have test coverage.
  2. Every new icon requires manually creating a new test file.
  3. There's a lot of duplicated boilerplate across files.

Contributor Guide

Activity

  1. self-assigned this
    on May 11, 2026
  2. Rajesh-Nagarajan-11 commented on May 11, 2026

    @Rajesh-Nagarajan-11
    Member

    Is it possible to dynamically tests all the icons?

  3. rishiraj38 commented on May 11, 2026

    @rishiraj38
    ContributorAuthor

    Yeah I think so! We could do a wildcard import from the icons barrel and dynamically loop over all exports with describe.each. I'll explore this and raise a PR.

  4. rishiraj38 commented on May 11, 2026

    @rishiraj38
    ContributorAuthor

    @Rajesh-Nagarajan-11
    I looked into this and yes we can dynamically test all icons with a single test file. Here's the approach I went with:

    We do import * as AllIcons from '../icons' to pull in everything from the barrel file, then filter for functions (since TS types get stripped at runtime). After that describe.each loops over every icon and runs 3 tests, renders without crashing, produces an <svg>, and forwards width/height props.

    This gives us 690 tests covering all 230 icon components, and the best part is it's zero maintenance, whenever someone adds a new icon and exports it from index.ts, the test picks it up automatically.

  5. Rajesh-Nagarajan-11 commented on May 11, 2026

    @Rajesh-Nagarajan-11
    Member

    Yeah, sounds good , go-ahead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions