fix(design-system): use mockdate in storybook tests instead of vi [AR-46279]#124
Conversation
|
you can add a |
Thanks for info. However, this is not obvious, I will add a few words about it to README. |
|
Something that bothers me the most - why our CI/CD didn't catch the fact that specific story is completely broken. |
please extract to its own pr since it's unrelated to this one
that's a great question... needs investigation EDIT: nvm, saw it in production |
When I compare what is more important:
It doesn't work locally, but all tests are passing. I assume Michal was so sure it works, that didn't check if story is rendered.
It would be nice to have a universal check that verifies stories can be rendered without errors. Do you have anything on your mind how we can achieve it? |
it's not for cleaner history, it's for easier revert and separation
I agree, but I don't have a good idea currently, since I assumed vitest is doing it |
This reverts commit 3b8f038.
|
@StyleShit all right, I can see the benefit of doing that, here: #127 |
Steps to reporoduce
Navigate to Storybook DateInput component.
You'll see error:
Root cause
In a nutshell, importing from vitest
import { vi } from 'vitest';breaks storybook. See details here.Solution
Use mockdate package to mock dates. I took the idea from Storybook documentation.
Alternative Solution
I also considered @sinonjs/fake-timers package since it is more popular and in active development, but it's usage looks a bit more complicated and its size is 103 kB versus 13.8 kB of mockdate