79093819

Date: 2024-10-16 11:28:34
Score: 0.5
Natty:
Report link

Ok, the solution was (it was one of my coworker's solution really).

In the Vitest config/setup file import expect and add the following:

import { expect /* and other imports */ } from 'vitest';

expect.addSnapshotSerializer({
  test: (val) => typeof val === 'string',
  print: (val) => `"${(val as string).replace(/css-[a-z0-9]*/g, 'css-test')}"`,
});

This will replace the hashed css classes with "css-test". 🙂

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Erik Kránicz