栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

摩卡+伊斯坦布尔+通天塔

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

摩卡+伊斯坦布尔+通天塔

使用Babel 6.x,假设我们有file

test/pad.spec.js

import pad from '../src/assets/js/helpers/pad';import assert from 'assert';describe('pad', () => {  it('should pad a string', () => {    assert.equal(pad('foo', 4), '0foo');  });});

安装一堆废话:

$ npm install babel-istanbul babel-cli babel-preset-es2015 mocha

创建一个

.babelrc

{  "presets": ["es2015"]}

运行测试:

$ node_modules/.bin/babel-node node_modules/.bin/babel-istanbul cover    node_modules/.bin/_mocha -- test/pad.spec.js  pad    ✓ should pad a string  1 passing (8ms)=============================================================================Writing coverage object [/Volumes/alien/projects/forked/react-flux-puzzle/coverage/coverage.json]Writing coverage reports at [/Volumes/alien/projects/forked/react-flux-puzzle/coverage]============================================================================================================ Coverage summary ===============================Statements   : 100% ( 4/4 )Branches     : 66.67% ( 4/6 ), 1 ignoredFunctions    : 100% ( 1/1 )Lines        : 100% ( 3/3 )================================================================================

更新 :我已经成功使用

nyc
(消耗
istanbul
)而不是
istanbul
/
babel-istanbul
。这有点复杂。尝试一下:

安装内容(您可以删除

babel-istanbul
babel-cli
):

$ npm install babel-core babel-preset-es2015 mocha nyc

.babelrc
如上创建。

执行此:

$ node_modules/.bin/nyc --require babel-core/register node_modules/.bin/mocha  test/pad.spec.js

…应该会给您类似的结果。默认情况下,它将覆盖率信息放入

.nyc-output/
,并在控制台中显示漂亮的文本摘要。

注意:

node_modules/.bin/
将命令放在
package.json
scripts
字段中时,可以从其中任何命令中删除。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/436606.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号