Socket
Socket
Sign inDemoInstall

mocha

Package Overview
Dependencies
7
Maintainers
1
Versions
195
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mocha

simple, flexible, fun test framework


Version published
Weekly downloads
7.6M
decreased by-0.79%
Maintainers
1
Install size
958 kB
Created
Weekly downloads
 

Package description

What is mocha?

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.

What are mocha's main functionalities?

Test Organization

Organize tests in suites and sub-suites using describe() and context(), and specify test cases using it().

"use strict";\nconst assert = require('assert');\ndescribe('Array', function() {\n  describe('#indexOf()', function() {\n    it('should return -1 when the value is not present', function() {\n      assert.equal([1, 2, 3].indexOf(4), -1);\n    });\n  });\n});

Asynchronous Testing

Support for testing asynchronous code with ease, using callbacks, promises, or async/await.

"use strict";\nconst assert = require('assert');\ndescribe('User', function() {\n  describe('#save()', function() {\n    it('should save without error', function(done) {\n      const user = new User('Luna');\n      user.save(function(err) {\n        if (err) done(err);\n        else done();\n      });\n    });\n  });\n});

Hooks

Lifecycle hooks such as before(), after(), beforeEach(), and afterEach() for setting up preconditions and clean-up after tests.

"use strict";\ndescribe('Connection', function() {\n  before(function() {\n    // runs once before the first test in this block\n  });\n\n  after(function() {\n    // runs once after the last test in this block\n  });\n\n  beforeEach(function() {\n    // runs before each test in this block\n  });\n\n  afterEach(function() {\n    // runs after each test in this block\n  });\n\n  // test cases\n});

Other packages similar to mocha

Readme

Source

Build Status

Mocha test framework

Mocha is a simple, flexible, fun JavaScript test framework for node.js and the browser. For more information view the documentation.

Contributors


 project  : mocha
 repo age : 1 year, 7 months
 active   : 272 days
 commits  : 1116
 files    : 123
 authors  :
   504  TJ Holowaychuk          45.2%
   389  Tj Holowaychuk          34.9%
    31  Guillermo Rauch         2.8%
    13  Attila Domokos          1.2%
     9  John Firebaugh          0.8%
     8  Jo Liss                 0.7%
     7  Nathan Rajlich          0.6%
     6  James Carr              0.5%
     6  Brendan Nee             0.5%
     5  Aaron Heckmann          0.4%
     4  hokaccha                0.4%
     4  Xavier Antoviaque       0.4%
     4  Joshua Krall            0.4%
     3  Wil Moore III           0.3%
     3  Jesse Dailey            0.3%
     3  Nathan Bowser           0.3%
     3  Tyson Tate              0.3%
     3  Cory Thomas             0.3%
     3  Ryunosuke SATO          0.3%
     3  Paul Miller             0.3%
     3  Ben Lindsey             0.3%
     2  Forbes Lindesay         0.2%
     2  Konstantin Käfer        0.2%
     2  Brian Beck              0.2%
     2  Merrick Christensen     0.2%
     2  Michael Riley           0.2%
     2  David Henderson         0.2%
     2  Nathan Alderson         0.2%
     2  Paul Armstrong          0.2%
     2  Pete Hawkins            0.2%
     2  Quang Van               0.2%
     2  Raynos                  0.2%
     2  Jonas Westerlund        0.2%
     2  Domenic Denicola        0.2%
     2  Shawn Krisman           0.2%
     2  Simon Gaeremynck        0.2%
     2  FARKAS Máté             0.2%
     2  Timo Tijhof             0.2%
     2  Justin DuJardin         0.2%
     2  Juzer Ali               0.2%
     2  Ian Storm Taylor        0.2%
     2  Arian Stolwijk          0.2%
     2  domenic                 0.2%
     1  Richard Dingwall        0.1%
     1  Russ Bradberry          0.1%
     1  Sasha Koss              0.1%
     1  Seiya Konno             0.1%
     1  Standa Opichal          0.1%
     1  Steve Mason             0.1%
     1  Will Langstroth         0.1%
     1  Yanis Wang              0.1%
     1  Yuest Wang              0.1%
     1  abrkn                   0.1%
     1  airportyh               0.1%
     1  fengmk2                 0.1%
     1  tgautier@yahoo.com      0.1%
     1  traleig1                0.1%
     1  vlad                    0.1%
     1  yuitest                 0.1%
     1  Adam Crabtree           0.1%
     1  Andreas Brekken         0.1%
     1  Atsuya Takagi           0.1%
     1  Austin Birch            0.1%
     1  Bjørge Næss             0.1%
     1  Brian Moore             0.1%
     1  Bryan Donovan           0.1%
     1  Casey Foster            0.1%
     1  Corey Butler            0.1%
     1  Dave McKenna            0.1%
     1  Fedor Indutny           0.1%
     1  Florian Margaine        0.1%
     1  Frederico Silva         0.1%
     1  Fredrik Lindin          0.1%
     1  Gareth Murphy           0.1%
     1  Gavin Mogan             0.1%
     1  Greg Perkins            0.1%
     1  Harry Brundage          0.1%
     1  Herman Junge            0.1%
     1  Ian Young               0.1%
     1  Ivan                    0.1%
     1  Jaakko Salonen          0.1%
     1  Jakub Nešetřil          0.1%
     1  James Bowes             0.1%
     1  James Lal               0.1%
     1  Jason Barry             0.1%
     1  Javier Aranda           0.1%
     1  Jeff Kunkle             0.1%
     1  Jonathan Creamer        0.1%
     1  Jussi Virtanen          0.1%
     1  Katie Gengler           0.1%
     1  Kazuhito Hokamura       0.1%
     1  Koen Punt               0.1%
     1  Laszlo Bacsi            0.1%
     1  László Bácsi            0.1%
     1  Maciej Małecki          0.1%
     1  Matt Robenolt           0.1%
     1  Matt Smith              0.1%
     1  Matthew Shanley         0.1%
     1  Michael Schoonmaker     0.1%
     1  Phil Sung               0.1%
     1  R56                     0.1%

Keywords

FAQs

Last updated on 03 Apr 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc