In this activity, you will work with a partner to dissect the provided testing example.
Open the index.js
file in your code editor and try to guess what what the code does. What do you think will be printed to the console in this example?
Run the index.js
file in your terminal. Was your guess correct? How do you think the method chaining is achieved?
Open the arithmetic.js
file in your code editor. What do you think the significance of the plus
and minus
methods returning new Arithmetic
is? How does this relate to the method chaining you saw in the index.js
file?
Open test/arithmetic.test.js
. What is the significance of the expect
function? What does toEqual
do? What about the describe
and it
functions? Where are these coming from?
Once you’ve had some time to consider the above, run npm run test
in your terminal and examine the output. Do you have a better idea of what the describe
and it
functions might be used for?
Have any conclusions, as well as remaining questions, ready to share during the activity review.