It is simpler to avoid capitalizing acroynms

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the workflows category.

Last Updated: 2024-11-21

I had trouble getting a jest (JavaScript testing library) mock to work

import * as pdfPreview from "../pdfPreview"
pdfPreview.displayPdf = jest.fn()

expect(pdfPreview.displayPdf.mock).toHaveReceived()

The problem was that the function's real name was displayPDF() (vs. displayPdf above) and there was no error thrown because I had mocked the wrong property . I got caught out because my function name used capitals in it, which is non-standard.

In future I should enforce that even acronyms are lowercase in my functions. Or adopt a convention at least.