Comments (2)
Install Mocha
Before writing any test you'll need to use Node.js and npm to set up a JavaScript project and install Mocha.
- Node allows you to run JavaScript in the terminal
- npm is a Node tool that allows you to download packages from the web, and manage them in a JavaScript project
- Mocha is one of those packages and is used to test other JavaScript code
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.
Initialize the project:
npm init
Install Mocha:
npm install mocha -D
You can view package.json in the text editor. You can now see mocha as a dependency.
from learningfs.
After installing Mocha as a dependency we can run it in two ways.
The first (and more tedious) method is to call it directly from node_modules:
./node_modules/mocha/bin/mocha
The second (and recommended) method is to add a script to package.json. In the scripts object in package.json, set the value of "test": "mocha". It should look like this:
"scripts": {
"test": "mocha"
}
Now you can call Mocha with the following command:
npm test
Instead of manually running each test in the test directory, you can use this command to run the full test suite automatically.
from learningfs.
Related Issues (20)
- Create Index CSS
- Render the radio buttons using the salaryData module
- Open up main.js and take a look at the function `renderInputButtons()`
- Replace empty arrays companies and roles
- Add a type=module attribute to script `<script src='main.js'>`
- from "./modules/salaryData.js"
- Create the workAroundModule
- Replace empty arrays in workAroundModule
- Export the four functions in workAroundModule
- Calculate and render the data when the user input changes HOT 1
- You are a collegue student a you want to stream a movie over one of the campuses WI-FI networks. Based on the number of users, some networks won't have the data to stream a movie. HOT 1
- A video game consist of two players floating using 100 helium balloons. HOT 2
- A shift cipher takes a plain text message and shifts each letter forward in the alphabet by a given number.
- describe and it blocks HOT 3
- assert HOT 1
- Setup, Exercise and Verify HOT 2
- Teardown HOT 5
- Hooks HOT 3
- Review
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from learningfs.