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

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.

11. Which of the following runtimes are typically used for building backends?

  • Cyprus
  • Jest
  • Protractor
  • Node.js

12. Which of the following is testing how parts of your system interact with other parts of your system?

  • Unit testing
  • Integration testing
  • End-to-end testing
  • Post-hoc testing

13. Node package manager (npm) is used to do which of the following?

  • Test code coverage.
  • Add code from places like Stack Overflow or github.
  • Build a back end.
  • Use a large number of libraries and frameworks as Node.js modules.

14. True or False: If you have built a project with different node packages, they will all be listed inside the package.json file.

  • True
  • False

15. A person on your team wants to help with testing. However, they are not a developer and cannot write code. What type of testing is most suited for them?

  • Integration testing
  • Post-hoc testing
  • Unit testing
  • End-to-end testing

16. What is the recommended way to separate the code that you are testing from its related dependencies?

  • End-to-end testing
  • module.exports
  • Fakes
  • Mocking

Leave a Reply