programming with javascript coursera week 4 quiz answers

Knowledge check: Introduction to testing

1. What is the correct way to export the timesTwo function as a module so that Jest can use it in testing files?

  • export module(timesTwo)
  • module(exported(timesTwo))
  • document.module.export = timesTwo
  • module.exports = timesTwo

2. Testing is a way to verify the expectations you have regarding the behavior of your code.

  • true
  • false

3. Node.js can be used to build multiple types of applications. Select all that apply.

  • Command line applications
  • Desktop applications
  • Web application backends

4. When the following test executes, what will the test result be?

function add(a, b) {
return a + b;
}

expect(add(10, 5)).toBe(16);

  • Success.
  • Fail.

5. Which of the following is the slowest and most expensive form of testing?

  • Unit testing
  • Integration testing
  • End-to-end testing (e2e)

6. Mocking allows you to separate the code that you are testing from its related dependencies.

  • true
  • false

Module quiz: Testing

7. What is unit testing?

  • Unit testing gives you an efficiency rating for your code measured in units.
  • Unit testing revolves around the idea of having separate, small pieces of code that are easy to test.
  • Unit testing tries to imitate how a user might interact with your app.
  • Unit testing is testing how parts of your system interact with other parts of your system.

8. When the following test executes, what format will the result be?

function subtract(a, b) { return a - b; } expect(subtract(10, 4)).toBe(6);

  • True/False
  • Success/Fail
  • Function
  • String

Shuffle Q/A 1

9. True or False: End-to-end testing is the slowest and most expensive type of testing.

  • True.
  • False

10. What is Code Coverage?

  • A measure of what percentage of your code has failing tests.
  • A measure of what percentage of your code is covered by tests.
  • What percentage of your code is complete.
  • What percentage of your code is in Javascript.

Leave a Reply