-
Notifications
You must be signed in to change notification settings - Fork 162
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
Mocking formatDate #248
Comments
# [2.1.0-develop.1](v2.0.1-develop.3...v2.1.0-develop.1) (2021-04-30) ### Features * Export `formatDate` and some other tool functions ([6142e11](6142e11)), closes [#248](#248)
🎉 This issue has been resolved in version 2.1.0-develop.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
🎉 |
Well, me is very sad and frustrated. Looks like jestjs/jest#936 explains that it isn't really possible to replace transitive function calls. I've now spent way too many hours trying to work my way around it, but it doesn't really seem possible. There are babel-powered solutions like https://github.com/speedskater/babel-plugin-rewire, but I don't get why I'd need to use extensive transpilation and that typescript doesn't offer this functionality itself. Solutions like this: https://stackoverflow.com/a/47976589/4682621 |
Oh my, beforeAll(() => {
jest.useFakeTimers('modern')
jest.setSystemTime(new Date(0))
})
afterAll(() => {
jest.useRealTimers()
}) just saved my well being. Sniff. |
🎉 This issue has been resolved in version 2.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hey there, before upgrading to v2 I want to add a test that asserts nothing breaks.
My issue is that the
DTSTAMP
is dynamically generated, so I cannot check for a static result. I first think of mocking the function, which provides the fields value to receive a predictable result:ical-generator/src/event.ts
Line 1348 in ac05fb6
But
formatDate
is not exported on the library level. How can I go about this then? Could we add it as exported member or is there a better way to do it?The text was updated successfully, but these errors were encountered: