In this article, you will learn how to use npm and MongoDB on your computer to run the Cake Bar application that you interacted with in the Why Test? course. You will also run the Cake Bar test suite from your terminal and see all the tests passing.

When you're done, spend some time looking through the application. Pay special attention to the structural similarities between the implementation code and the test code in the test directory.

If you get stuck during the below steps and can't resolve the issue by yourself, your fellow learners might be able to help! Post the following information in a Slack message to your cohort: (i) the full error message, (ii) your node and npm versions, and (iii) steps to reproduce the issue. Run node -v and npm -v to find your versions.

Setup the Why Test? Example application:

Mac

  1. Download the source code for the Cake Bar web application.
  2. Unzip the folder you just downloaded.
  3. Skip this step if you already have a MongoDB process running. If not, open a new command line session, and use the following command to start a new MongoDB instance.
    $ mongod --dbpath ~/data/db
  4. Keep your current terminal session open and open a new terminal window. In your new terminal session, navigate to the Cake Bar directory that you unzipped. You can navigate to the Cake Bar directory by typing cd into your command line, then dragging and dropping the Cake Bar folder from your finder.
  5. Run npm install to download all of the required node packages for the Cake Bar application.
  6. From your command line, run npm test to execute the Cake Bar test suite. After a few seconds you should see all of the tests pass in your terminal. (If you don't see all tests passing, go to server.config.js and change 8001 to 8000.)
  7. Run npm start to start your server. When you see "listening on port 4001", move to the next step.
  8. In your browser, visit http://localhost:4001 to see the Cake Bar application.
  9. Celebrate!

Windows

  1. Download the source code for the Cake Bar web application.
  2. Unzip the folder you just downloaded.
  3. If you don't have MongoDB running in the background already, open the powershell, and use the following command to start a new mongo instance. The following command works for MongoDB version 3.4. If you’ve downloaded a different version, replace "3.4" with the version number.

    & 'C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe'


  4. Open Git Bash. In your new session, navigate to the Cake Bar directory that you unzipped. You can navigate to the Cake Bar directory by typing cd into your terminal, then dragging and dropping the Cake Bar folder from your finder.
  5. Run npm install to download all of the node packages the application requires.
  6. Run npm test to run the Cake Bar test suite. After a few seconds, you should see all of the tests pass in your terminal. (If you don't see all tests passing, go to server.config.js and change 8001 to 8000.)
  7. Run npm start to load the application's dependencies and start your server.
  8. Visit http://localhost:4001 to see the application in your browser.
  9. Celebrate!
Made in NYC © 2018 Codecademy