Unit testing

In test-driven development, we will write testing code before we implement a function.  In this lab, I use a Facebook framework – Jest to test JavaScript code.

To install it.

npm install --save-dev jest

 

To code the test code.

  1. require the modal
  2.  Test for each function with describe(String, function)
  3. For each function, passing different arguments to the function and specify the expected result.

Finally I got this code.

Capture.PNG

In this case,

Description: “returns true for student myseneca address

Argument: someone@myseneca.ca

Excepted result: true

 

Capture.PNG

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s