OSDN Git Service

Regular updates
[twpd/master.git] / mocha.md
1 ---
2 title: Mocha.js
3 category: JavaScript libraries
4 layout: 2017/sheet
5 ---
6
7 ### BDD
8
9     mocha.setup('bdd');
10
11     describe('something', function() {
12       beforeEach(function() {
13       });
14
15       it('should work', function() {
16       });
17     });
18
19 ### Async
20
21     it('should save', function(done) {
22       var user = new User();
23       user.save(function(err) {
24         if (err) throw err;
25         done();
26       });
27     });
28
29 ### Chai: Shoulds
30
31     chai.should();
32
33     foo.should.be.a('string');
34     foo.should.equal('bar');
35     foo.should.have.length(3);
36     tea.should.have.property('flavors').with.length(3);
37
38 ### See also
39
40  * [Mocha TDD](mocha-tdd.html)
41  * [Mocha HTML](mocha-html.html)
42  * [Chai](chai.html)
43  * [Sinon](sinon.html)
44  * [Sinon Chai](sinon-chai.html)