Question: Welcome to the Interplanetary Science Fair! In this assignment, you will be creating a module that calculates the distance between two planets in our solar

Welcome to the Interplanetary Science Fair! In this assignment, you will be creating a module that calculates the distance between two planets in our solar system. You will be using Test Driven Development (TDD) principles and the Node.js assert library to guide your development process. For this assignment, we will be using Astronomical Units (AU) to measure distances. 1 AU is the average distance between the Sun to the Earth. You will need to research and find the approximate distance of the planets from the Sun in AU. Remember, these are average values, as the actual distances vary as the planets orbit the Sun. Instructions:
1. Create a new folder for your project following this structure:
distance-calculator
src
distance-calculator.js
test
distance-calculator.spec.js
package.json
2. In your package.json file, add a test script. Remember to use strict mode. 3. Your distance-calculator.js module should include a function that calculates the distance between two planets in AU, given their distances from the sun in AU.
4. For the function in your module, write three (3) diKerent unit tests in the distancecalculator.spec.js using the Node.js assert library. Each test should set up a scenario, call the function with specific inputs, and then assert that the functions output is correct.
5. Each test should be wrapped in a function named testFunctionDescription, where functionDescription is a brief description of what the test does. For example, a test that checks if the function correctly calculates the distance between Earth and Mars could be named testEarthToMars.
6. Inside each test function, use a try/catch block to run the test and catch any errors. If the test passes, print a message indicating it passed and return true. If the test fails, print a message indicating the test failed and return false. Below is an example to get you started:
function testEarthToMars(){
try {
assert.strictEqual(calculateDistance('Earth', 'Mars'), expectedValue);
return true;
} catch (error){
console.error(`Failed testEarthToMars: ${error.message}`);
return false; }}
7. Use TDD principles to guide your development process. Write your tests first, then write the code to make the tests pass.
Grading: You will be awarded 20 points for each passing unit test, for a total of 60 points. If a test does not pass, you will not receive points for that test. Use the provide starter files to complete the assignment. ```
JS distance-calculator.js
JS distance-calculator.js > calculateDistance
1 function calculateDistance(planet1, planet2){
// TODO: Implement this function
}
module.exports = calculateDistance;
``````
JS distance-calculator.spec.js
JS distance-calculator.spec.js >...
1 const assert = require('assert');
const calculateDistance = require('../src/distance-calculator');
function testFunctionDescription(){
// TODOF Implement this function
}
// Call your test functions here
```
Welcome to the Interplanetary Science Fair! In

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!