Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Advanced JavaScript
  • Table Of Contents Toc
Advanced JavaScript

Advanced JavaScript

By : Zachary Shute
3.5 (4)
close
close
Advanced JavaScript

Advanced JavaScript

3.5 (4)
By: Zachary Shute

Overview of this book

If you are looking for a programming language to develop flexible and efficient applications, JavaScript is an obvious choice. Advanced JavaScript is a hands-on guide that takes you through JavaScript and its many features, one step at a time. You'll begin by learning how to use the new JavaScript syntax in ES6, and then work through the many other features that modern JavaScript has to offer. As you progress through the chapters, you’ll use asynchronous programming with callbacks and promises, handle browser events, and perform Document Object Model (DOM) manipulation. You'll also explore various methods of testing JavaScript projects. In the concluding chapters, you'll discover functional programming and learn to use it to build your apps. With this book as your guide, you'll also be able to develop APIs using Node.js and Express, create front-ends using React/Redux, and build mobile apps using React/Expo. By the end of Advanced JavaScript, you will have explored the features and benefits of JavaScript to build small applications.
Table of Contents (9 chapters)
close
close

Chapter 4: Testing JavaScript


Activity 4 – Utilizing Test Environments

You have been tasked with upgrading your Fibonacci sequence test code to use the Mocha test framework. Take the Fibonacci sequence code and test code you created for Activity 1 and upgrade it to use the Mocha test framework to test the code. You should write tests for the n=0 condition, then implement the n=0 condition, then write tests for and implement the n=1 condition, then write tests for and implement the n=2 condition, and finally do so for the n=5, n=7, and n=9 conditions. If the it() test passes, call the done callback with no argument. Otherwise, call the test done callback with an error or other truthy value.

To utilize the Mocha test framework to write and run tests, follow these steps:

  1. Set up the project directory with npm run init. Install mocha globally with npm install mocha -s -g.

  2. Create index.js to hold the code and test.js to hold the tests.

  3. Add the test script to package.json in the scripts field. The test...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Advanced JavaScript
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon