Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
better-dependency-injection-with-laconia
const { handler } = require("./lambda");
let twitterService;
beforeEach(() => {
// Creates a mocked twitterService
twitterService = {
getLatestTweets: jest.fn().mockReturnValue(Promise.resolve())
};
});
it("should get tweets for user 1000", () => {
// Runs your exported handler function with the mocked dependencies
handler.run({ twitterService });
expect(twitterService.getLatestTweets).toBeCalledWith(1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment