Mocha (JavaScript framework)

Short description: JavaScript test framework running on Node.js

Mocha

Developer(s)| OpenJS Foundation
Initial release| Script error: No such module "Date time".
Stable release|

10.0.0 / 1 May 2022; 3 years ago (2022-05-01)

Repository| github.com/mochajs/mocha
Written in| JavaScript
Platform| Node.js
Type| Test automation framework
License| MIT
Website| mochajs.org

Mocha is a JavaScript test framework for Node.js programs, featuring browser support, asynchronous testing, test coverage reports, and use of any assertion library.[1]

## Contents

* 1 Assertion libraries
* 2 Usage and examples
* 3 See also
* 4 References
* 5 External links

## Assertion libraries

Mocha can be used with most JavaScript assertion libraries, including:

* should.js
* express.js
* chai
* better-assert
* unexpected

## Usage and examples

$ npm install -g mocha
$ mkdir test
$ $EDITOR test/test.js # or open with your favorite editor

var assert = require("assert")
describe('Foo', function(){
describe('#getBar(value)', function() {
it('should return 100 when value is negative') // placeholder
it('should return 0 when value is positive', function() {
assert.equal(0, Foo.getBar(10));

$  mocha

1 test complete (1ms)

For asynchronous testing, invoke the callback, and Mocha will wait for completion.

describe('Foo', function(){
describe('#bar()', function() {
it('should work without error', function(done) {
var foo = new Foo(128);
foo.bar(done);

## See also

* Jasmine
* List of unit testing frameworks
* npm
* QUnit
* Unit.js
* JavaScript framework
* JavaScript library

## References

1. ↑ "Mocha - the fun, simple, flexible JavaScript test framework" (in en). https://mochajs.org/.

## External links

* on GitHub

* v
* t
* e

JavaScript

Code analysis|

* ESLint
* JSHint
* JSLint

Transcompilers|

* Babel.js
* CoffeeScript
* LiveScript
* Dart
* Emscripten
* Google Closure Compiler
* Google Web Toolkit
* Morfik
* TypeScript
* AtScript
* Opa
* Nim
* Haxe
* ClojureScript
* WebSharper
* PureScript
* Reason
* Elm

Concepts|

* Client-side
* JavaScript library
* JavaScript syntax
* Unobtrusive JavaScript

Debuggers|

* Firebug
* Komodo IDE
* Microsoft Script Debugger
* Microsoft Script Editor
* Opera Dragonfly
* Web Inspector

Doc generators|

* JSDoc

Editors (comparison)|

* Ace
* Cloud9 IDE
* Atom
* CodeMirror
* Light Table
* Brackets
* Koding
* PhpStorm
* Orion
* Visual Studio
* Visual Studio Express
* Visual Studio Code
* Visual Studio Team Services

Engines|

* Comparison of engines
* DOM support
* List of ECMAScript engines

Frameworks|

* Comparison of JavaScript frameworks
* List of JavaScript libraries

Related technologies|

* Cascading Style Sheets
* Document Object Model
* HTML
* Dynamic HTML
* Ajax
* JSON
* WebAssembly
* asm.js

Package managers|

* npm

Application Bundlers|

* Webpack

Server-side|

* Active Server Pages
* CommonJS
* JSGI
* Node.js
* Wakanda

Unit testing|

* Jasmine
* Mocha
* QUnit
* List of JavaScript unit testing frameworks
* Jest

People|

* Douglas Crockford
* Brendan Eich
* John Resig

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Mocha (JavaScript framework). Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:Mocha_(JavaScript_framework)&oldid=801102"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template