Skip to content

Instantly share code, notes, and snippets.

@Kalimaha
Created December 16, 2020 02:15
Show Gist options
  • Save Kalimaha/ec02236f4f883f705660866515933392 to your computer and use it in GitHub Desktop.
Save Kalimaha/ec02236f4f883f705660866515933392 to your computer and use it in GitHub Desktop.
FFS
import { eggs } from "../src/eggs";
import { spam } from "../src/spam";
describe("normal", () => {
it("does some calculations", () => {
expect(eggs(3)).toEqual(72);
});
});
describe("mocked", () => {
// Override `spam` to return 100
it("does some calculations", () => {
expect(eggs(3)).toEqual(142);
});
});
import { spam } from "./spam";
export const eggs = (a: number) => 42 + spam(a);
export const spam = (a: number): number => 10 * a;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment