Solution: Troubleshooting Next.js Components with Jest

Review the step-by-step solution to the exercise.

In this exercise, your task was to implement the following tests:

  • Check if the image displayed by the ArticleCard is a valid image (not something else).

  • Check when you utilize the composeArticleSlug function with an article's title, it doesn’t return an empty string.

Let’s review the solution for each task.

Testing the ArticleCard component

You can find the solution code for this method here:

Get hands-on with 1400+ tech skills courses.