Assuming you already have installed mocha
, zombie
and expect.js
according to instructions, this should work for you:
// Put below in a file in your *test* folder, ie: test/sampletest.js:
var expect = require('expect.js'),
Browser = require('zombie'),
browser = new Browser();
describe('Loads pages', function(){
it('Google.com', function(done){
browser.visit("http://www.google.com", function () {
expect(browser.text("title")).to.equal('Google');
done();
});
});
});
Then you should be able to run the mocha
command from your root application folder:
# mocha -R spec
Loads pages
? Google.com (873ms)
? 1 tests complete (876ms)
Note: If your tests keep failing due to timeouts, it helps to increase mocha
's timeout setting a bit by using the -t
argument. Check out mocha's documentation for complete details.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…