我來教教你前端自動化單元測試如何做(8)
發表于:2016-09-22來源:segmentfault作者:acrens點擊數:
標簽:前端
() { it( null object , function () { var result = typeofAndInstanceOf(); console .log(result); expect([ object , false ]).toEqual(result); });}); /** - test index.js checkOperators method - detail: -
() {
it(
'null object',
function() {
var result = typeofAndInstanceOf();
console.log(result);
expect([
'object',
false]).toEqual(result);
});
});
describe(
'test null is object',
function() {
it(
'test operator preceence',
function() {
var result = checkOperators();
console.log(result);
expect(
'Something').toEqual(result);
});
});
運行 sudo npm run test 執行測試代碼
"scripts": {
"test": "karma start karma.conf.js"
}
結果:

解答
-
npm run test 運行的實際上是 package.json 中配置的命令:
原文轉自:https://segmentfault.com/a/1190000006969924