美文网首页技术雷达
JavaScript test framework : Moch

JavaScript test framework : Moch

作者: 光剑书架上的书 | 来源:发表于2018-09-26 17:02 被阅读17次

    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. Hosted on GitHub.

    https://mochajs.org/#reporters

    INSTALLATION

    Install with npm globally:

    $ npm install --global mocha
    
    

    or as a development dependency for your project:

    $ npm install --save-dev mocha
    
    

    Mocha currently requires Node.js v6.x or newer.

    GETTING STARTED

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

    In your editor:

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

    相关文章

      网友评论

        本文标题:JavaScript test framework : Moch

        本文链接:https://www.haomeiwen.com/subject/fhljoftx.html