COURSE 8: MOBILE DEVELOPMENT AND JAVASCRIPT QUIZ ANSWERS
Week 4: Testing and Compatibility
Meta Android/IOS Developer Professional Certificate
Complete Coursera Answers & Study Guide
Enroll in Coursera Meta IOS Developer Professional Certification
Enroll in Coursera Meta Android Developer Professional Certification
Testing and Compatibility INTRODUCTION
Here you will learn about Node.js and npm. And you will explore how to install npm packages and how to work with package.json. Furthermore, you will learn about testing in JavaScript and you’ll code a simple unit test in Jest.
Learning Objectives
- Describe Node.js and npm
- Explain how to install npm packages
- Describe how to work with package.json
- Explain the process of testing in JavaScript
- List the three most prevalent kinds of testing
- Demonstrate how to code a simple unit test in Jest
SELF REVIEW: WRITING A UNIT TEST
1. Did you complete the Writing a Unit Test exercise?
- Yes (CORRECT)
- No
Well done on completing the exercise!
2. Were there any parts of Writing a Unit Test exercise that you found difficult to complete?
- Yes
- No (CORRECT)
Thank you for completing the Writing a Unit Test exercise.
3. Would you say that you are able to explain, in your own words, what are unit tests?
- Yes (CORRECT)
- No
Great! Being able to describe newly-learned concepts in your own words is a reflection of a better understanding of the subject matter.
4. Which of the following statements are true for Node.js?
- Node.js can run in multiple settings, for example, on the command line, in a desktop application, or on the back-end of a web app (on a server). (CORRECT)
- Node.js is a separate, standalone environment without ties to the JavaScript in the browser. (CORRECT)
- Node js is only active on the front-end.
Well done. Node.js can run in multiple settings, for example, on the command line, in a desktop application, or on the back-end of a web app (on a server). And it’s a completely separate, standalone environment without ties to the JavaScript in the browser.
Well done. Node.js can run in multiple settings, for example, on the command line, in a desktop application, or on the back-end of a web app (on a server). And it’s a completely separate, standalone environment without ties to the JavaScript in the browser.
5. Which of the following is a correct example of a Jest test?
- expect(concatStrings(“123”, “456”)).toBe(“123456”); (CORRECT)
- concatStrings(“123″,”456”); // “123456”
Yes, the above code is an example of a JavaScript testing framework syntax.
6. Which type of testing involves the process of testing the smallest units of your source code in isolation?
- End-to-end testing
- Unit testing (CORRECT)
- Integration testing
Yes, unit testing involves the process of testing the smallest units of your source code in isolation.
7. Which of the following features does Jest provide? Check all that apply.
- Jest can be used to write unit tests. (CORRECT)
- A range of frameworks can be tested with Jest. (CORRECT)
- Jest supports code coverage. (CORRECT)
That’s correct! Jest allows you to easily work with unit tests.
That’s correct! Jest lets developers test a range of code types.
That’s correct! Jest uses code coverage to measure what percentage of code is covered by tests.
8. What will happen when you run this piece of code on the command line at the root of your project’s folder: npm install –save-dev jest?
- It will add Jest globally to my machine.
- It will add Jest as a dependency inside package.json.
- It will add Jest as a devDependency inside package.json. (CORRECT)
You are correct! When you run this piece of code on the command line at the root of your project’s folder it will add Jest as a devDependency inside package.json.
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 (CORRECT)
That’s correct! This is the correct way to export the function.
2. Testing is a way to verify the expectations you have regarding the behavior of your code.
- true (CORRECT)
- false
That’s correct! Testing is good practice as a software engineer for verifying expectations.
3. Node.js can be used to build multiple types of applications. Select all that apply.
- Command line applications (CORRECT)
- Desktop applications (CORRECT)
- Web application backends (CORRECT)
That’s correct! Command line applications can be built with using Node.js.
That’s correct! Desktop applications can be built with using Node.js.
That’s correct! Backends can be built with using Node.js.
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. (CORRECT)
That’s correct! The expectation will fail as the function will return 15 which does not equal 16.
5. Which of the following is the slowest and most expensive form of testing?
- Unit testing
- Integration testing
- End-to-end testing (e2e) (CORRECT)
That’s correct! End-to-end testing (e2e) is the most expensive as these tests take the most time to set up and run.
6. Mocking allows you to separate the code that you are testing from its related dependencies.
- true (CORRECT)
- false
That’s correct! Mocking allows you to isolate the code being tested in your unit tests.
Following the TDD approach has many benefits. Select all the benefits following the TDD approach has for you as a developer. Check all that apply.
- Minimize regressions. (CORRECT)
- Implementations can be tested using various inputs. (CORRECT)
- Stress-test your application.
- Run your infrastructure more efficiently.
That is correct! The benefits the TDD approach has for you, as a developer, is Minimizing regression and the fact that your implementations can be tested using various inputs.
That is correct! The benefits the TDD approach has for you, as a developer, is Minimizing regression and the fact that your implementations can be tested using various inputs.
Coursera Meta Android Developer Professional Certificate Answers and Study Guide
Liking our content? Then don’t forget to ad us to your bookmarks so you can find us easily!
Weekly Breakdown | Meta Study Guides | Back to Top
MODULE QUIZ: TESTING
1. What is unit testing?
- Unit testing revolves around the idea of having separate, small pieces of code that are easy to test. (CORRECT)
- 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 our system.
That’s correct! Unit testing is focused on testing small, specific “units” of code.
2. When the following test executes, what will the test result be?
function subtract(a, b) {
return a - b;
}
expect(subtract(10, 4)).toBe(6);
- Success. (CORRECT)
- Fail.
That’s correct! The function will return 6 and the expectation will succeed.
3. What is End-to-end testing (e2e)?
- End-to-end testing revolves around the idea of having separate, small pieces of code that are easy to test.
- End-to-end testing tries to imitate how a user might interact with your application. (CORRECT)
- End-to-end testing is testing how parts of your system interact with other parts of our system.
That’s correct! End-to-end testing mimics how users will interact with your application.
4. 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. (CORRECT)
That’s correct! Code coverage shows what percentage of your code is covered by tests and where more testing may be required.
5. Node.js can be used to build web application backends.
- true (CORRECT)
- false
That’s correct! Node.js is a popular JavaScript runtime for building backends.
6. When the following test executes, what will the test result be?
function multiply(a, b) {
return a;
}
expect(multiply(2, 2)).toBe(4);
- Success.
- Fail. (CORRECT)
That’s correct! The function will fail because it has a bug which returns only the a variable. Therefore, 2 is returned from the function which does not match the expectation.
7. Which command is used to install a Node package?
- package
- pkg
- node
- npm (CORRECT)
That’s correct! The Node Package Manager (npm) is used to install packages.
8. Which file lists all your application’s required node packages?
- node.json
- npm.json
- package.json (CORRECT)
- pkg.json
That’s correct! package.json will store all the dependencies required for application.
9. 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?
- Unit testing
- Integration testing
- End-to-end testing (CORRECT)
That’s correct! End-to-end tests can be performed in a web browser without writing code. This is because the tests mimic how a user will interact with the application.
10. What is the recommended way to separate the code that you are testing from its related dependencies?
- Mocking (CORRECT)
- module.exports
- End-to-end testing
That’s correct! Mocking allows developers to simulate the behaviour of dependent code during tests.
Subscribe to our site
Get new content delivered directly to your inbox.
Quiztudy Top Courses
Popular in Coursera
- Meta Marketing Analytics Professional Certificate.
- Google Digital Marketing & E-commerce Professional Certificate.
- Google UX Design Professional Certificate.
- Meta Social Media Marketing Professional Certificate
- Google Project Management Professional Certificate
- Meta Front-End Developer Professional Certificate
Liking our content? Then, don’t forget to ad us to your BOOKMARKS so you can find us easily!