logoalt Hacker News

z3t4today at 6:40 AM0 repliesview on HN

If you make the function pure it will be easier to test. Pass the moving parts as function parameters, then you can pass in the mocks in the actual functions when testing. Example:

    f = () => a+b
refactor for easier testing

    f = (a, b) => a+b
in your test you can now mock a and b