Is it time to execute a mocha test?

Good day, I am currently exploring the world of software testing and recently installed Mocha. However, I seem to be encountering an issue with running a basic test that involves comparing two numbers. Can someone please guide me on why this is happening and how I can resolve it?

Json

{  "scripts": {
  "test": "mocha test/**/*.js"
},
  "name": "image-gallery",
  "version": "1.0.0",
  "description": "",
  "main": "script-test.js",
  "directories": {
    "test": "script-test.js"
  },
 
  "author": "",
  "license": "ISC"
}

Test.js

const assert = require('assert');

describe('number test', function() {
    it('matching numbers', function() {
      assert.ok(2 === 2);
    });
  });

Answer №1

Have you added mocha to your project by executing this command in the directory?

npm install --save-dev mocha

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Disabling the shadow when setting the face color in Three.js

When creating geometric objects in my project, I am randomly setting colors on the faces: // Material used to create the mesh var material = new THREE.MeshLambertMaterial({ color: 0xffffff, ambient: 0xffffff, vertexColors: THREE.FaceColors}) function ad ...

Error encountered while parsing JSON data for dynamic charts in Chart.js

I am currently in the process of constructing dynamically generated graphs utilizing technologies such as Chart.js, jQuery, JSON, Mustache.js, and Twitter Bootstrap. All the data required for these graphs is stored within a JSON file, which is then used i ...

Filtering data within a specific date range on an HTML table using JavaScript

I am attempting to implement a date filtering feature on my HTML table. Users should be able to input two dates (From and To) and the data in the "Date Column" of the table will be filtered accordingly. The inputs on the page are: <input type="date" i ...

The onScroll event is failing to trigger when scrolling to a particular div on Next.js

Is there a way to fetch data when a specific div comes into view on a SSR page in Next.js? I attempted using the onScroll event on the div, but it doesn't seem to be triggering. Any suggestions? function handleScroll() { console.log("scrolled ...

Limit the implementation of Angular Material's MomentDateAdapter to strictly within the confines of individual

Within my app, I have several components that utilize the mat-datepicker. However, there is one component where I specifically want to use the MomentDateAdapter. The issue arises when I provide it in this one component as it ends up affecting all the other ...

Creating a one-of-a-kind entry by adding a number in JavaScript

I am looking for a way to automatically add an incrementing number to filenames in my database if the filename already exists. For example, if I try to add a file with the name DOC and it is already present as DOC-1, then the new filename should be DOC-2. ...

Sort products by the subcategory in Firebase

I am currently facing a challenge in filtering products based on their sub child nodes within Firebase. This is how my data is structured: products/ product1 /author: 12345 /title: "Awesome" /description: "more awesome" ...

Issue with Parsley validation not functioning as expected

I have implemented parsley.js to validate my form, but I am facing an issue when trying to validate a checkbox using the data-mincheck attribute. Below is the snippet of my code: <form data-validate="parsley"> <p>Please choose at least 2 ...

Having trouble creating a PDF from HTML

Having trouble with generating PDFs using various libraries as I keep encountering the following error: Fatal Error: spawn UNKNOWN The code snippet looks like this: mammoth.convertToHtml({ path: './backend/common/template.docx' } ...

unable to display loading image prior to upload

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html lang="en"> <head> <title>Unique Prints</title> <meta charset="utf-8"> <meta name="viewport" conte ...

Creating interactive network visualizations using JavaScript

I've been in search of javascript code that can help me create a visual representation similar to this example. Specifically, I need something that can display links between boxes when clicked on or hovered over. I'm still not sure what this par ...

Utilize the function of express

The following code is not behaving as expected: var express = require('express'); var app = express(); app.use(function(req, res, next) { console.log('first statement'); next(); }, function (req, res, next) { console.log('se ...

Vercel - Deploying without the need to promote the project

How can I deploy my Nextjs app to production in a way that allows me to run E2E tests on a "pre-prod" version before promoting it to prod, similar to using a preview URL without public traffic being directed there? I am looking for a process where I can v ...

React.map does not retrieve the specific value

I am facing an issue with my list of items. I have implemented it using mui list, and I have also added a button for editing the list. However, when I click on an item, I am getting the value of the last item instead of the one I clicked on. Below is my f ...

Encountering issues in inserting data with duplicate IDs in a many-to-many relationship

I currently have a situation where I have two entities, Movie and Actor, that are linked together in a many-to-many relationship. Here is the definition of the Movie entity: public class Movie { @Id private String imdbId; @ManyToMany(cascade ...

Choosing arbitrary data points from a JSON document

I've been working on a program to randomly pick and display questions from a list stored in a `.json` file. Here's the current code I have: import json import random with open("C:\\LearningArabic\\LiblibArriby\\Les ...

Creating a private variable to perform a select_sum query

I have defined private variables in my CodeIgniter code like this: private $table = 'phone'; private $column_order = array(null, 'name', 'price'); private $type = array('type'); private $battery_consumption = array ...

Importing data from JSON file stored in the assets folder in NUXT.js framework

If I have a file named assets/data/geo/regions.json in my NUXT.js project's folder structure, what is the best way to read data from it into my project? I attempted to use axios, but I am uncertain of the URL for this file as I have tested various po ...

Is it possible to extract the version_name using the version_code of an android package?

Is it possible to retrieve the version_name by using the version_code of an Android package? For instance: 'com.nianticlabs.pokemongo' version_code: 2017121800 => version_name: 0.87.5 I'm looking for a function that can accomplish th ...

Displaying the chosen array in a Material UI Table within a React application does not show the desired checkboxes

After days of hard work and research, I finally figured out how to achieve what I needed. In my React App, I have a Material UI table that I want to load with pre-rendered checks in the DOM based on entries in a selected array. The selected array contains ...