Skip to content

Instantly share code, notes, and snippets.

@Nalini1998
Last active April 20, 2023 22:13
Show Gist options
  • Save Nalini1998/baa295ebdef992e22487d8287c9e225b to your computer and use it in GitHub Desktop.
Save Nalini1998/baa295ebdef992e22487d8287c9e225b to your computer and use it in GitHub Desktop.
Install Mocha I Part 1
[How to install Mocha Part 1?](https://www.codecademy.com/journeys/full-stack-engineer/paths/fscj-22-front-end-development/tracks/fscj-22-javascript-testing/modules/wdcp-22-write-good-tests-with-mocha-764e85ca-0abf-4da9-91a2-43f8d593eab8/lessons/automate-organize-tests/exercises/install-mocha-i)
1. Before writing any tests you’ll need to use Node.js and npm to set up a JavaScript project and install Mocha;
2. Node allows you to run JavaScript in the terminaL;
3. `npm` is a **Node tool** that allows you to download packages from the web, and manage them in a JavaScript project;
4. Mocha is one of those packages and is used to test other JavaScript code;
5. A JavaScript project is a directory of files. The following command creates a file package.json that can be used to manage packages for the project.
`
$ npm init
`
After running this command you will be prompted to enter information about your project. It’s okay to skip some fields if you’re not ready to enter that information.
With your project setup, you can install packages.
`
$ npm install mocha -D
`
**Here’s what this command means:**
npm install tells npm to install a package from the internet and any other packages it depends on
mocha is the package you want to download
-D signifies that this package is a development dependency and will show up under the devDependecies section in package.json. This means that the package will only be included in development mode and will not be included in the production bundle.
Once you npm install packages, you can find the packages and all their dependencies in the node_modules folder. The new directory structure contains the following:
**project**
|_ node_modules
|___ .bin
|___ mocha
|___ ...
|_ package.json
The ... in the file structure represents other packages that are a dependency for Mocha.
@Nalini1998
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment