Commit 025e1ef
authored
chore: update unit testing cursor rule for theme mocks (MetaMask#27825)
## **Description**
Updates `.cursor/rules/unit-testing-guidelines.mdc` with clearer
guidance for theme-related mocks in unit tests:
- Prefer `mockTheme` (real design tokens) instead of hardcoded hex
values.
- Mock `useTailwind()` with the correct return shape (supports
`tw.style(...)`, and only add `tw.color(...)` when the component under
test uses it).
This is intended to reduce churn and align new tests with the
`@metamask/design-tokens/color-no-hex` ESLint rule.
Related / prior `color-no-hex` PRs:
- MetaMask#26958
- MetaMask#26963
- MetaMask#27008
- MetaMask#27030
- MetaMask#27031
- MetaMask#27149
- MetaMask#27150
- MetaMask#27151
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: Cursor unit testing guidelines
Scenario: guidance for theme-related mocks is clear
Given a developer is writing or updating a unit test
When they follow the updated theme mocking guidance
Then they can avoid hardcoded hex colors and mock useTailwind without type/shape mismatches
```
## **Screenshots/Recordings**
### **Before**
N/A
### **After**
N/A
## **Pre-merge author checklist**
- [x] I've followed MetaMask Contributor Docs and MetaMask Mobile Coding
Standards.
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable (N/A)
- [x] I've documented my code using JSDoc format if applicable (N/A)
- [x] I've applied the right labels on the PR (see labeling guidelines).
Not required for external contributors.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Low risk: documentation-only change that updates testing guidance
without affecting runtime behavior.
>
> **Overview**
> Updates `.cursor/rules/unit-testing-guidelines.mdc` to add **Theme
Mocking Rules** that steer tests toward using the shared `mockTheme` and
away from hardcoded hex design tokens (to align with
`@metamask/design-tokens/color-no-hex`).
>
> Adds concrete mock examples for `useTheme`, `useStyles`, and
`useTailwind()` (including the correct return shape), plus an explicit
anti-pattern example of local hex color mock objects.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
6227068. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 75bef55 commit 025e1ef
1 file changed
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
237 | 297 | | |
238 | 298 | | |
239 | 299 | | |
| |||
0 commit comments