- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我使用以下代码,它能够按预期生成 Mocha 测试(套件和测试)报告,但我无法看到 Istanbul 尔的 Mocha 测试覆盖率我在这里错过了什么?
gulp.task('test', function () {
gulp.src(['./assets/**/js/*.js'])//Here I took it from the repo
.pipe(istanbul())
.pipe(tap(function (f) {
require(f.path);
}))
.on('end', function () {
gulp.src(['test/*spec.js'])//this is the path for my tests
.pipe(mocha({
reporter: 'mochawesome'
}))
.pipe(istanbul.writeReports(
['unit-test-coverage']
));
});
});
以下内容不会生成任何内容
.pipe(istanbul.writeReports(
['unit-test-coverage']
));
我的项目如下所示
my app
-server.js
-app.js
-contoller
--file1.js
--file2.js
-test
spec1.js
spec2.js
-gulpfile.js
我使用以下 https://github.com/SBoudrias/gulp-istanbul喝一口 Mocha https://www.npmjs.com/package/gulp-mocha
这是代码运行后得到的结果
19 次通过(15 秒)
[mochawesome] Report saved to mochawesome-reports/mochawesome.html
----------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
----------|----------|----------|----------|----------|----------------|
All files | 100 | 100 | 100 | 100 | |
----------|----------|----------|----------|----------|----------------|
=============================== Coverage summary ===============================
Statements : 100% ( 0/0 )
Branches : 100% ( 0/0 )
Functions : 100% ( 0/0 )
Lines : 100% ( 0/0 )
================================================================================
更新当我执行以下操作时,它会生成一份报告,但覆盖率很高,但似乎代码覆盖率不是很好,因为我得到了 100% 的所有测试(我希望:-)),知道我在这里错过了什么吗?由于 Mocha 单元测试运行良好,只是代码覆盖率效果不佳
.pipe(istanbul.writeReports({
dir: './assets/unit-test-coverage',
reporters: ['html'],
reportOpts: {dir: './unit-test-coverage'}
}));
更新2
我在 GRUNT 中构建了相同的内容(因为我在这里迷路了:-( ),这正在工作!!!!!!
但我仍然想让它在 Gulp 中工作,请帮忙!
我尝试分离所有依赖项并创建这个小 gulp 文件并运行只是它,仍然是同样的问题
这是新文件,我使用不同的技术,但结果相同:(
var gulp = require('gulp');
var istanbul = require('gulp-istanbul');
var mocha = require('gulp-mocha');
gulp.task('pre-test', function () {
return gulp.src(['./assets/**/js/*.js'])
// Covering files
.pipe(istanbul(
{includeUntested: true}
))
.pipe(istanbul.hookRequire());
});
gulp.task('test', ['pre-test'], function () {
return gulp.src(['test/*spec.js'])
.pipe(mocha({
reporter: 'mochawesome'
}))
// Creating the reports after tests ran
.pipe(istanbul.writeReports({
dir: './assets/unit-test-coverage',
reporters: ['html'],
reportOpts: {dir: './unit-test-coverage'}
}))
.pipe(istanbul.enforceThresholds({thresholds: {global: 90}}));
});
gulp.task('default', [ 'test']);
我在这里缺少什么?测试文件运行正常,只是覆盖范围...
最佳答案
正如评论中所说。
您似乎没有 assets
文件夹。至少“我的项目如下”没有它。尝试一下
return gulp
// all js files from cwd excluding test folder and gulpfile
.src(['./**/*.js', '!test/', '!gulpfile.js'])
.pipe(istanbul(...))
关于javascript - Gulp mocha Istanbul 尔 免费获得 100%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38556061/
我正在使用 mocha 和 chai 进行 TDD 以测试一些 NodeJS 脚本,每次我想再次运行测试时都必须运行“mocha”。 有没有办法设置 mocha 和 chai 在我保存源文件后立即运行
如果任何测试失败,我正在尝试配置 mocha 以重试整个套件。 我导航到一个 URL,然后填充一个表单并提交,然后用户被重定向,如果找到某个元素,则最后一次测试通过。 如果找不到该元素,我需要再次导航
我想知道是否有办法让 mocha 列出它将执行的所有测试。当我使用 mocha --help 列出它们时,我没有看到任何合理的选项;有几个报告者,但似乎没有一个旨在列出将要处理的文件(或命名将要运行的
before()、after()、beforeEach()、afterEach() 等 mocha Hook 无法正常工作。 only 方法也不起作用。 beforeEach 都没有被调用。我得到一个
我已经看到很多关于此的问题,但所有修复都不适用于我的代码。 我做错了什么?我的 beforeEach 没有被执行。 这是单元测试代码: var assert = require('assert');
如何在 mocha 测试之间共享资源(例如连接)? cookies.test.js: describe('Cookies', function() { it('setCookie()', func
我正在尝试以编程方式运行 mocha。 runner的代码如下: var Mocha = require("mocha"); var mocha = new Mocha(); mocha.report
我正在遵循此 tutorial 的第 1 步 我有以下文件夹结构: ├── lib │ ├── json │ │ ├── messages.json │ │ └── testMessages.json
我希望能够扩展 mocha 测试结果并从可用的 mocha 对象中收听它们。首先,我正在寻找“通过”结果。 看起来他们可能是从套件中订阅的,但我不确定如何...... 我尝试了以下我认为会听到我所有测
我正在运行此测试(简化),该测试按预期失败了……但是,尽管失败了,但它仍要等待20秒的全部超时时间。如何使它立即失败? it("should fail before timeout", functio
我是Java语言世界的新手,主要涉足OOP。我试图在网上查找Karma和 Mocha 之间的明显区别,但徒劳无功。我知道Karma是一个测试运行器,而Mocha是一个单元测试框架,但是Mocha也有自
我有一段代码,其中某些测试在 CI 环境中总是会失败。我想根据环境条件禁用它们。 如何在运行时执行期间以编程方式跳过 mocha 中的测试? 最佳答案 您可以通过在describe或it block
我想使用 chai 应该断言检查我的响应对象是否包含提到的属性。 下面是我的代码片段: chai.request(app) .post('/api/signup') .
例如,默认情况下,背景颜色为绿色或红色。我想将绿色/红色作为前景,将背景作为我的默认颜色(白色)。 因为在浅色终端配色方案上很难看到任何东西,因为前景是黑色的,而背景会变成红色或绿色。 最佳答案 在
有没有办法在 mocha 记者中获取当前测试的文件名? 我在基础和示例中找不到任何内容。 最佳答案 实际上,文件名在 中传递给了 Suite文件 Mocha 中的字段从 this 开始拉取请求。只是现
在我走向 TDD 的过程中,我使用了 Mocha、chai 和 sinon。 那里肯定有一个学习曲线。 我的目标是编写一个测试来验证 method4 是否已执行。我如何做到这一点? //MyData.
我正在使用mocha和chai作为断言。 我在规范中有几个主张: Exp1.should.be.true Exp2.should.be.true Exp3.should.be.true 如果其中之一失
根据 Mocha 文档,“Mocha 测试串行运行”这意味着按照它们的定义顺序。 我的问题是:是什么让 异步 (带有完成回调)测试不同于 同步 ? 最佳答案 您通过传递给 it 来告诉 Mocha 测
我正在尝试将 mocha 绑定(bind)写入 PureScript 并且对 Control.Monad.Eff 完全感到困惑 describe(function(){ //do stuff }
我对 mocha 框架有点陌生。此代码应该抛出异常,但不会。 (为简单起见,将所有代码放入测试中) describe("Test", function() { it("this should
我是一名优秀的程序员,十分优秀!