Skip to content

test: add lint rule to prevent new snapshot tests#28582

Open
cortisiko wants to merge 5 commits intomainfrom
MMQA-1673
Open

test: add lint rule to prevent new snapshot tests#28582
cortisiko wants to merge 5 commits intomainfrom
MMQA-1673

Conversation

@cortisiko
Copy link
Copy Markdown
Member

@cortisiko cortisiko commented Apr 9, 2026

Description

Adds an ESLint enforcement to phase out Jest file-based snapshots.

Test files (.test./.spec.) now error on expect(...).toMatchSnapshot() via jest/no-restricted-matchers, encouraging toMatchInlineSnapshot() or explicit assertions instead.

Changelog

CHANGELOG entry:

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Low Risk
Low risk: adds a test-only ESLint restriction and a devDependency update; no runtime code paths are affected. Potential friction is limited to new/modified Jest tests that currently use toMatchSnapshot().

Overview
Adds a new ESLint override for *.test.*/*.spec.* files that errors on expect(...).toMatchSnapshot(), pushing tests toward toMatchInlineSnapshot() or explicit assertions to phase out file-based snapshots.

Updates tooling by adding eslint-plugin-jest (and lockfile resolution) to support the new lint rule.

Reviewed by Cursor Bugbot for commit 4ae43d1. Bugbot is set up for automated code reviews on this repo. Configure here.

@metamaskbot metamaskbot added the team-qa QA team label Apr 9, 2026
@github-actions github-actions bot added the risk-low Low testing needed · Low bug introduction risk label Apr 9, 2026
@cortisiko cortisiko added no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed and removed risk-low Low testing needed · Low bug introduction risk labels Apr 9, 2026
@github-actions github-actions bot added the size-S label Apr 9, 2026
@github-actions github-actions bot added the risk-low Low testing needed · Low bug introduction risk label Apr 9, 2026
@github-actions github-actions bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 9, 2026
@github-actions github-actions bot removed the risk-low Low testing needed · Low bug introduction risk label Apr 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 98%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes in this PR are purely developer tooling/linting configuration:

  1. package.json: Added eslint-plugin-jest as a devDependency. This is a linting tool only used during development/CI linting checks, not bundled into the app.

  2. .eslintrc.js: Added a new ESLint rule for test files (*.test.*, *.spec.*) that disallows toMatchSnapshot() in favor of toMatchInlineSnapshot(). This is a code quality enforcement rule that only affects the linting step, not runtime behavior.

  3. yarn.lock: Updated automatically to reflect the new dependency.

None of these changes affect:

  • Application runtime code or behavior
  • UI components, rendering, or user flows
  • Controllers, state management, or Engine
  • Navigation or screen transitions
  • E2E test infrastructure or test execution
  • Any feature that E2E tests validate

These changes have zero impact on E2E test outcomes. No E2E tags need to run.

Performance Test Selection:
The changes are purely ESLint/linting configuration changes (adding eslint-plugin-jest and a new rule to prevent file-based snapshots). There is no impact on app performance, rendering, state management, or any runtime behavior. No performance tests are needed.

View GitHub Actions results

@github-actions github-actions bot added the risk-low Low testing needed · Low bug introduction risk label Apr 9, 2026
@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​eslint-plugin-jest@​29.14.0 ⏵ 29.15.199 +110010097 -2100

View full report

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 9, 2026

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

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed risk-low Low testing needed · Low bug introduction risk size-S team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants