词条 | Mocha (JavaScript framework) |
释义 |
}}{{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 LibrariesMocha can be used with most JavaScript assertion libraries, including:
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}}
ReferencesExternal links
3 : JavaScript libraries|JavaScript programming tools|Software using the MIT license |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。