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
Cache persistence doesn't work #464
Comments
I've managed to overcome this limitation using nasty hack, but this is a clearly not the best workaround.
On a side not I would love to see more time-manipulation available for tests. What happens when cache just expired, etc. I would like to include that into integration tests. |
Hey! 👋 Happy new year! Just catching up with issues now. 🙂 When using the
With the Miniflare Jest environment, you should be able to use Jest's standard timer mocks (https://jestjs.io/docs/timer-mocks), specifically with https://jestjs.io/docs/jest-object#jestsetsystemtimenow-number--date to test cache expiry. |
@mrbbot, I see the logic behind it. However this is somewhat unexpected. When I create an instance of some object, and use in my test I won't expect it to have same fancy logic around tests. Could you please add this into documentation? Also, there is no way to save-restore cache state, which bloats tests. |
Initially I thought this is my configuration issue, but then I found this topic: https://community.cloudflare.com/t/testing-workers-with-the-cache-api/181346
However solution from that discussion wont help me. My caching results already had caching reply status. I've noticed that sometimes the caching behavior is unexpected to me, and decided to write tests to address that issue. However, it seems that even with correct wrangler.toml, cache wont be persistent if miniflare was created as part of a jest test.
It seems that between tests the cache being reset, and I don't see any files created in my selected cache folder. I have 500 lines worker with complicated caching logic, and I would like to have tests cover all the corner cases.
https://github.com/cloudflare/miniflare/blob/master/packages/shared-test-environment/src/storage.ts#L43
The text was updated successfully, but these errors were encountered: