请输入您要查询的百科知识:

 

词条 Mocha (JavaScript framework)
释义

  1. Assertion Libraries

  2. Usage and examples

  3. See also

  4. References

  5. External links

{{multiple issues|{{unreferenced|date=August 2014}}{{notability|Products|date=August 2014}}

}}{{Other uses|Mocha (disambiguation){{!}}Mocha}}

{{Infobox software
| name = Mocha
| title = Mocha
| logo =
| screenshot =
| caption =
| collapsible =
| author =
| developer =
| released = {{Start date|2011|11|22|df=yes/no}}
| discontinued =
| latest release version = 4.0.1
| latest release date = {{release date and age|df=yes|2017|10|05}}
| latest preview version =
| latest preview date =
| frequently updated =
| programming language = JavaScript
| operating system =
| platform =
| size =
| language =
| status =
| genre = Test automation framework
| license = MIT
| website = {{URL|http://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.

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

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

{{Portal|Free and open-source software}}
  • Jasmine
  • List of unit testing frameworks
  • npm
  • QUnit
  • Unit.js
  • Jest

References

External links

  • [https://github.com/mochajs/mocha GitHub repository]
  • Guide to mocha
{{JavaScript}}

3 : JavaScript libraries|JavaScript programming tools|Software using the MIT license

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/13 19:59:05