Testing Vue.js Components
Plans from $25/month

This lesson is for members. Join us?

Subscribe now to get instant access to this course, plus a full library of Vue.js courses tailored to the plan you choose.

🚧 PLEASE NOTE: An updated version of this course is available! see the Rapid Testing with Vitest: Master Unit Testing & Mocking course. This course is outdated!

Learn How To Test Computed Properties and Watchers

In this lesson, we’ll learn how to test one of our favorite features of Vue.js, computed properties, and watchers.

There is also a testing exercise at the end of the lesson.

Exercise:

Create a test that given a string ending with f, as a temp prop.

Expect that the fahrenheit computed property must be a number equal to the prop without the f suffix.

The celsius computed property should convert the Fahrenheit to Celsius.

Example:

Given temp: ’50f’ , vm.farenheight should be 50 and vm.celcius should be 10.

Click here to view the solution.