我来教教你前端自动化单元测试如何做(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