Mock it till you drop it: API and Service mocking support is here #1008
marcuskohlberg
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
With v1.30.0 we're now introducing support for mocking APIs and services! This makes it much simpler to test your application in isolation.
Let's look at an example:
You have an endpoint that calls an external API in our products service:
When testing this function, you don't want to call the real external API since that would be slow and cause your tests to fail if the API is down. Instead, you want to mock out the API call and return a fake response.
You can now do this in Encore by adding a mock implementation of the endpoint using the
et.MockEndpoint
function inside your test:In addition to mocking individual APIs, you can also mock entire services. This can be useful if you want to inject a different set of dependencies into your service for testing, or a service that your code depends on.
When mocking services, Encore will automatically generate an
Interface
interface for every service, which contains all the APIs defined in the service. This makes it possible to automatically generate mock objects for your services using either Mockery or GoMock.📚Check out the docs for all the details.
Improved docs search
We've updated the docs search functionality to make it easier to find what you're looking for. Search now has improved relevancy, snippets are much improved, and results can now link directly to sub-sections of individual pages.
Roadmap
We're currently pushing to get TypeScript support out the door and hope to release the first general availability in the next few weeks.
We've also been working on some smaller features based on your comments on Slack which will drop in the next few days: cloud cost insights and the ability to pause and trigger cron jobs from the Cloud Dashboard.
Check out the roadmap and leave your comments!
Thanks to all contributors
🙏 We continue to be overwhelmed by your support, feedback, and suggestions!
Together we're building the future of backend development and we couldn't be more excited.
❤️ As always, we're excited to hear what you think!
Please share your feedback on Slack.
Full Changelog: v1.29.7...v1.30.0
This discussion was created from the release Mock it till you drop it: API and Service mocking support is here.
Beta Was this translation helpful? Give feedback.
All reactions