Daily Dispatch 28 - Jesting

Daily Dispatch 28 - Jesting

Hey it’s me again, so I’ve been learning how to work with Jest, one testing library used by some React projects.

Here are my thoughts:

  • Compared to other testing libraries like JUnit or Kotlin’s test, I saw it as a bit less organized.
  • I still don’t know why exactly I felt that way.

Some errors:

  • mockImplementationOnce is not a functionJest at:
     it('loads initial data', async () => {
       const getPrismicClientMocked = mocked(createPrismicClient)  
       const clientMocked = {
          query: jest.fn().mockResolvedValueOnce({
              results: [
                    uid: 'my-new-post',
                    data: {
                        content: [
                         {type: 'heading1', text: 'My new post'},
                         {type: 'paragraph', text: 'Post excerpt'}
                    last_publication_date: '04-01-2021'

       getPrismicClientMocked.mockImplementationOnce( (config) => { // Error here
          return clientMocked as any
  • How I solved it:
    • I forgot to add at the top of the file this line
      typescript jest.mock('../services/prismic')
    • To tell the code that my functions at prismic would be called as mocks.

That is it for today.