????avalon1.6?????ò???????????????????????п???????????黯?????????????????
????ui???????????????????e????totoro??????????????????????webdrieverio?? nightwatch???????karma??
????karma?????????????????tò???????????
?????????npm????У?
????karma
????karma-mocha
????karma-mocha-reporter
????karma-firefox-launcher
????karma-chrome-launcher
????karma-opera-launcher
????karma-safari-launcher
????????????????karma.config.js
module.exports = function (config) {
config.set({
basePath: ''??
frameworks: ['mocha']??
files: [
{pattern: 'node_modules/chai/chai.js'?? include: true}??
'karma/index.js'
]??
exclude: []??
reporters: ['mocha']??
mochaReporter: {
output: 'autowatch'??
colors: {
success: 'green'??
info: 'bgGreen'??
warning: 'cyan'??
error: 'bgRed'
}
}??
port: 9876??
colors: true??
logLevel: config.LOG_INFO??
//autoWatch?true??Karma???????в???????
autoWatch: true??
//http://www.cnblogs.com/NetSos/p/4371075.html
browsers: ['Opera'??'Chrome'?? 'Firefox'??"Safari"]??
singleRun: false??
plugins: [
'karma-mocha'??
'karma-mocha-reporter'??
'karma-firefox-launcher'??
'karma-chrome-launcher'??
'karma-opera-launcher'??
'karma-safari-launcher'
]
})
}
??????????????????н????????karma?????????潨index.js
/**
* Created with IntelliJ IDEA.
* User: shenyanchao
* Date: 3/5/13
* Time: 5:51 PM
* To change this template use File | Settings | File Templates.
*/
var assert = chai.assert;
var should = chai.should();
describe('Array'?? function(){
before(function(){
console.log('this called in before all');
});
beforeEach(function(){
console.log('invoke before each method');
});
afterEach(function(){
console.log('invoke after each method');
});
after(function(){
console.log('this called in after all');
});
describe('#indexOf()'?? function(){
it('should return -1 when the value is not present'?? function(){
console.log('invoke one assert');
assert.equal(-1?? [1??2??3].indexOf(5));
assert.equal(-1?? [1??2??3].indexOf(0));
});
});
describe('#indexOf()'?? function(){
it('should return -1 when the value is not present'?? function(){
console.log('invoke second should');
[1??2??3].indexOf(5).should.equal(-1);
[1??2??3].indexOf(0).should.equal(-1);
});
});
})
??????????karma start?????????Ч??