Skip to content

Implement React Snapshot tests#353

Open
luciagirasoles wants to merge 14 commits into
mainfrom
implement-react-snapshot-tests
Open

Implement React Snapshot tests#353
luciagirasoles wants to merge 14 commits into
mainfrom
implement-react-snapshot-tests

Conversation

@luciagirasoles

Copy link
Copy Markdown
Collaborator

📸 Implement React Snapshot Testing

Summary

This PR implements snapshot testing for React components using Jest and @emotion/jest, providing automated visual regression testing for the frontend codebase.

Changes Made

✅ Jest Configuration

  • Added Jest configuration in package.json with support for:
    • jsdom test environment for React testing
    • CSS/SCSS module mocking with identity-obj-proxy
    • Emotion snapshot serializer for styled components
  • Created jest.setup.js with Testing Library and Emotion matchers

✅ Testing Infrastructure

  • Added yarn test:frontend command to run all frontend tests including snapshots
  • Updated existing CI workflow to use the new test command
  • Maintained compatibility with existing JavaScript tests

✅ Component Tests

  • Implemented comprehensive tests for Button component including:
    • Snapshot tests for different prop combinations
    • Functional tests for user interactions and state management
    • Integration with existing SCSS styling

✅ Documentation

  • Updated README.md with:
    • New test commands
    • Snapshot testing workflow explanation
    • Guidelines for updating snapshots

Testing

  • All existing tests continue to pass
  • New snapshot tests generate and validate correctly
  • CI pipeline integrates seamlessly with existing workflow

Benefits

  • Visual regression detection: Automatically catch unintended UI changes
  • Component documentation: Snapshots serve as living documentation
  • Faster code reviews: Clear visual diffs for component changes
  • Consistent styling: Ensures Emotion styles are captured correctly

Usage

# Run all frontend tests (including snapshots)
yarn test:frontend

# Update snapshots after intentional changes
yarn test -u

# Run specific component tests
yarn test Button.test.jsx

@luciagirasoles luciagirasoles self-assigned this Oct 2, 2025
@luciagirasoles luciagirasoles changed the title Implement Snapshot tests Implement React Snapshot tests Oct 2, 2025
@luciagirasoles luciagirasoles force-pushed the implement-react-snapshot-tests branch 4 times, most recently from ec2a10d to 60d60b0 Compare October 2, 2025 10:13
@luciagirasoles luciagirasoles force-pushed the implement-react-snapshot-tests branch from 60d60b0 to 96461d0 Compare October 2, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant