OSDN Git Service

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