Mochajs

Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases.

Some of the features of mocha are as follow:

  • simple async support, including promises.
    async test timeout support.
    before, after, before each, after each hooks (very useful to clean the environment where each test!).
    test coverage reporting.

1)Installing mocha with npm globally in terminal

npm install –global mocha

2)Making directory

mkdir test

3)Knowing version of mocha

which mocha

4)Creating package.json file

“scripts”: {
“test”: “mocha”
}

5)Run test with;

npm test

6)Creating addition.js file in test folder

‘use strict’;

var assert=require(“assert”);
describe(‘addition’, function () {
it(‘should add 5+6 correctly’, function (done) {

var a = 5 + 6;
assert(a===11);
done();
});
});

7)Running addition.js in terminal

mocha test/addition.js //test folder

8)Using reporter in browser

npm install –save-dev mochawesome
mocha test/addition.js –reporter mochawesome

9)Using different reporter

mocha test/addition.js –reporter progress
mocha test/addition.js –reporter nyan


Posted

in

by

Tags:

Recent Post

  • What is Knowledge Distillation? Simplifying Complex Models for Faster Inference

    As AI models grow increasingly complex, deploying them in real-time applications becomes challenging due to their computational demands. Knowledge Distillation (KD) offers a solution by transferring knowledge from a large, complex model (the “teacher”) to a smaller, more efficient model (the “student”). This technique allows for significant reductions in model size and computational load without […]

  • Priority Queue in Data Structures: Characteristics, Types, and C Implementation Guide

    In the realm of data structures, a priority queue stands as an advanced extension of the conventional queue. It is an abstract data type that holds a collection of items, each with an associated priority. Unlike a regular queue that dequeues elements in the order of their insertion (following the first-in, first-out principle), a priority […]

  • SRE vs. DevOps: Key Differences and How They Work Together

    In the evolving landscape of software development, businesses are increasingly focusing on speed, reliability, and efficiency. Two methodologies, Site Reliability Engineering (SRE) and DevOps, have gained prominence for their ability to accelerate product releases while improving system stability. While both methodologies share common goals, they differ in focus, responsibilities, and execution. Rather than being seen […]

  • Moving Beyond Traditional Chatbots: Autonomous Agents Redefining Business Operations

    What if your business could operate on autopilot, with AI systems making crucial decisions and managing tasks in real time? Imagine autonomous agents—advanced AI systems capable of making decisions and performing tasks without constant human oversight—transforming your operations. From streamlining workflows to performing seamless customer interactions, these smart agents promise to redefine efficiency and innovation.  […]

  • Mastering Large Action Models: Unleashing Potential and Navigating Complex Challenges in AI

    Imagine an AI assistant that doesn’t just follow commands but anticipates your needs, makes decisions for you, and carries out tasks autonomously. This is the promise of Large Action Models (LAMs), a revolutionary step beyond current AI capabilities. Unlike traditional AI, which reacts to commands, LAMs can think ahead and manage complex scenarios without human […]

  • Harnessing Multimodal AI: A Comprehensive Guide to the Future of Data-Driven Decision Making

    Artificial Intelligence (AI) has been evolving at an astonishing pace, pushing the boundaries of what machines can achieve. Traditionally, AI systems handles single-modal inputs—meaning they could process one type of data at a time, such as text, images, or audio. However, the recent advancements in AI have brought us into the age of multimodal AI, […]

Click to Copy