Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to mock moment() in jest? #227

Open
alirezahmz opened this issue Dec 19, 2021 · 0 comments
Open

how to mock moment() in jest? #227

alirezahmz opened this issue Dec 19, 2021 · 0 comments

Comments

@alirezahmz
Copy link

i'm using moment-jalaali": "^0.9.4",
i get this error when i try to run test : moment is not a function
and after google it, i found this code:
jest.mock('moment', () => ({
format: () => '2018–01–30T12:34:56+00:00'
}));
and run again
get this error: TypeError: moment.localeData is not a function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant