Knowledge check: Introduction to testing in Javascript

Knowledge check: Introduction to testing in Javascript

  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