This PR adds unit tests for the Tailwind preset package to ensure that all CSS color variables used in the preset align with those defined in the @metamask/design-tokens package. Specifically, it verifies:
CSS variables defined in the preset exist in the design tokens stylesheet
CSS variables that aren't defined in the preset but exist in the stylesheet
Filtering using starts with prefix e.g. --color for color object
Ensuring that no missing or incorrect CSS variables exist, preventing breakage due to mismatched or non-existent variables.
Tailwind shortened class names work for text, background and border.
Tailwind preset configuration is correct
This change improves the reliability of the Tailwind preset by ensuring consistency with the design tokens.
Description
This PR adds unit tests for the Tailwind preset package to ensure that all CSS color variables used in the preset align with those defined in the
@metamask/design-tokens
package. Specifically, it verifies:--color
for color objectThis change improves the reliability of the Tailwind preset by ensuring consistency with the design tokens.
Related issues
Fixes: https://github.com/MetaMask/metamask-design-system/issues/48
Manual testing steps
yarn
in the root of themetamask-design-system
.yarn workspace @metamask/design-system-tailwind-preset jest
to confirm that tests pass.colors.ts
, change a CSS variable to one that doesn't exist in thedesign-tokens
package.yarn workspace @metamask/design-system-tailwind-preset jest
to confirm the tests fail.node_modules/@metamask/design-tokens/dist/styles.css
, add a color token--color-random: #000000
.yarn workspace @metamask/design-system-tailwind-preset jest
to confirm the tests fail.Screenshots/Recordings
After
The recording demonstrates tests validating the stylesheet CSS against a preset color object and the Tailwind preset configuration.
colors.test.ts
https://github.com/user-attachments/assets/9aa006b0-4a39-4e00-8174-64acdd88bcf9
index.test.ts
https://github.com/user-attachments/assets/321f274d-03e9-47c3-9cc1-85ad7ab189b0
100% test coverage
Pre-merge author checklist
Pre-merge reviewer checklist