JavaScript Unit Testing Competency (Intermediate Level)

  • 30m
  • 30 questions
The JavaScript Unit Testing Competency benchmark will assess your ability to recognize the different features available in Mocha, such as before/after hooks, asynchronous operations using promises and async/await, the configuration of Mocha reporters, and running Mocha in the browser. You will be evaluated on your skills in using the classic Assert API and the Expect/Should API to test numbers, booleans, strings, objects and object properties, and arrays in Chai. You will also be measured on your knowledge of using fakes, spies, stubs, and mocks in Sinon and using fake timers and sandboxes to write unit tests. A learner who scores high on this benchmark demonstrates that they have skills to work with the different Mocha features, Chai assertion libraries, and Sinon.

Topics covered

  • compare numeric values using assert
  • configure different reporters in Mocha
  • configure fakes with specific behavior
  • control time in tests to make asynchronous testing easy
  • create and use anonymous spies for testing
  • create an object to be used in test cases
  • create stubs for object methods
  • describe the assertions that can be used to test objects and their properties
  • implement tests using multiple hooks
  • install Mocha and Sinon on your local machine
  • instantiate objects without invoking object constructors
  • perform asynchronous function testing using expect
  • perform asynchronous testing using async/await
  • perform asynchronous tests using fakes with promises
  • perform testing using mocks and set expectations
  • perform testing using spies on object getters and setters
  • prepare Mocha tests to run within a browser
  • recognize how to test errors and callbacks with fakes
  • recognize the use of the beforeEach() and afterEach() hooks in tests
  • run multiple tests from the command line
  • spy on specific methods of an object
  • test different data types using expect
  • test different data types using should
  • test real world components using spies
  • test the order of function invocations using fakes
  • use arrays and elements in arrays using assert
  • use fake timers with multiple async functions
  • use sandboxes to simplify testing
  • use spy calls to test function invocations
  • use the done() method to signal test completion