JSTest - gpawade/gpawade.github.io GitHub Wiki
describe('hooks', function() {
before(function() {
// runs before all tests in this block
});
after(function() {
// runs after all tests in this block
});
beforeEach(function() {
// runs before each test in this block
});
afterEach(function() {
// runs after each test in this block
});
// test cases
});
beforeEach(function() {
// beforeEach hook
});
beforeEach(function namedFun() {
// beforeEach:namedFun
});
beforeEach('some description', function() {
// beforeEach:some description
});
describe('User', function() {
describe('#save()', function() {
it('should save without error', function(done) {
/// call done when asyn work is done
});
});
});
The exclusivity feature allows you to run only the specified suite or test-case by appending .only()
to the function.
describe('Array', function() {
describe.only('#indexOf()', function() {
// ...
});
});
This feature is the inverse of .only()
. By appending .skip()
, you may tell Mocha to simply ignore these suite(s) and test case(s)
describe('Array', function() {
describe.skip('#indexOf()', function() {
// ...
});
});
// Retry all tests in this suite up to 4 times
this.retries(4);
//To tweak what’s considered “slow”, you can use the slow() method:
this.slow(10000);
//
this.timeout(500);
//use this.timeout(0) to disable the timeout for a hook.
suite("suite name", function(){
setup(function(){
// initial setup
});
})