节点和npm的最新版本导致运行业力的问题.当我尝试安装karma-cli时,npm i -g karma karma-cli我收到以下警告:
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.8
npm WARN optional Skipping failed optional dependency /gulp-karma/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@0.2.1
Run Code Online (Sandbox Code Playgroud)
当我尝试运行时karma test,我得到以下错误:
"C:\Program Files\nodejs\node.exe" "C:\Program Files (x86)\JetBrains\WebStorm 11.0.3\plugins\js-karma\js_reporter\karma-intellij\lib\intellijServer.js" --karmaPackageDir=C:\Users\xxx\AppData\Roaming\npm\node_modules\karma --configFile=C:\Users\xxx\Documents\project\karma.conf.js
26 02 2016 11:24:07.871:WARN [plugin]: Cannot find plugin "karma-chrome-launcher".
Did you forget to install it ?
npm install karma-chrome-launcher --save-dev
26 …Run Code Online (Sandbox Code Playgroud) 早上好,
我有一个奇怪的问题,我似乎无法解决.我已经写出了我的Karma测试并且执行正确,但是当我尝试连接Karma的代码覆盖时,无论如何都会吐出100%.
我看了一下这里提出的其他问题,似乎没有一个问题可以解决我的问题.任何帮助将不胜感激.
使用:
"karma": "~0.12.37",
"karma-babel-preprocessor": "^5.2.1",
"karma-browserify": "^4.2.1",
"karma-coverage": "^0.4.2",
"karma-jasmine": "~0.3.5",
"karma-phantomjs-launcher": "^0.2.0",
Run Code Online (Sandbox Code Playgroud)
这是我的karma.conf.js
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['browserify', 'jasmine'],
files: [
'bower_components/jquery/dist/jquery.js',
'bower_components/angular/angular.js',
'bower_components/angular-animate/angular-animate.js',
'bower_components/angular-cookies/angular-cookies.js',
'bower_components/angular-mocks/angular-mocks.js',
'bower_components/angular-resource/angular-resource.js',
'bower_components/angular-sanitize/angular-sanitize.js',
'bower_components/angular-touch/angular-touch.js',
'bower_components/angular-ui-router/release/angular-ui-router.js'
'src/*.html',
'src/**/*.html',
'src/app/index.js',
'src/app/**/*.js'
],
exclude: [],
preprocessors: {
'src/app/index.js': ['browserify', 'coverage'],
'src/app/**/*.js': ['browserify', 'coverage']
},
browserify: {
debug: true,
transform: ['babelify', 'stringify']
},
reporters: ['progress', 'coverage'],
port: 9876,
colors: true,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false
});
};
Run Code Online (Sandbox Code Playgroud)
我的文件结构是:
src …Run Code Online (Sandbox Code Playgroud) 我正在使用gulp-karma并面临一个简单的问题,但似乎无法找到我做错了什么.
gulp.task('test', function (done) {
karma.start({
configFile: __dirname + '..\\test\\' +'\karma.conf.js',
singleRun: true
}, done);
});
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的代码,我似乎无法在文件夹目录中返回1级.当我做它上面刚刚附加的..\文件夹direcotry没有去1个水平回(这是通常的使用的..\).以下是文件夹结构.
parent|
test|karma.conf.js
webapirole|gulpfile.js
Run Code Online (Sandbox Code Playgroud)
我的文件夹在webapirole文件夹中.我想返回1个文件夹并进入包含karma.conf.js文件的测试文件夹.任何人都可以让我明白我在这里做错了什么?
我得到的错误
[18:06:32] Starting 'tdd'...
ERROR [config]: File C:\Users\Documents\WebApiRole..\test\karma.conf.js does not exist
Run Code Online (Sandbox Code Playgroud) 根据这篇文章(和一般互联网),如果我想在没有这些代码覆盖命令的情况下运行Karma测试...
__cov_9C0014nbzu2SxN3FICah6Q.f['35']++;
__cov_9C0014nbzu2SxN3FICah6Q.s['138']++;
Run Code Online (Sandbox Code Playgroud)
...我只需要--debug在终端中设置选项,如下所示:
$ karma start karma.conf.js --browsers=Chrome --single-run=false --debug
Run Code Online (Sandbox Code Playgroud)
但是,当通过Gulp任务运行Karma测试时,文档似乎丢失了.我在karma.start下面使用一个简单的配置对象.我已经尝试将debug属性设置为truestrit或者strign '--debug',但是似乎都没有效果(虽然测试确实运行/跑步者不会崩溃).
karma.start({
configFile: __dirname + '/karma.conf.js',
exclude: excludeFiles,
singleRun: !!singleRun,
debug: '--debug'
}, karmaCompleted);
Run Code Online (Sandbox Code Playgroud)
从Gulp任务运行Karma测试时如何设置调试选项的任何想法?
Karma测试运行正常但1如果0 of 0运行测试则退出代码.有谁知道如何返回退出代码0并在这种情况下正常退出?gulp-karma在没有运行规范时使用哪个操作失败.
我试图通过gulp任务运行业力测试.我使用https://github.com/karma-runner/gulp-karma,由于某种原因,gulp找不到我的karma.conf.js.该文件与gulpfile位于同一文件夹中.项目的根源.无论我放置什么路径,我都会得到相同的错误文件./karma.conf.js不存在.我无法弄清楚如何正确地路径.这是gulp任务的代码.
gulp.task('tdd', function (done) {
new Server({
configFile: 'karma.conf.js'
}, done).start();
});
Run Code Online (Sandbox Code Playgroud) 我只是在我的Karma配置文件中尝试了一些东西,并且有一个像这样的文件数组:
files: [
'../dist/app/**/*.mock.js',
'../dist/assets/scripts/bower_libs.js',
'../dist/assets/scripts/main.js',
'../test/src/**/*.js',
'../dist/app/**/*.spec.js'
],
Run Code Online (Sandbox Code Playgroud)
我知道我可以在这里使用一个basePath,例如配置中的basePath:'../dad /',这样就不需要在某些路径上加上'../dist/'.但是如果我的测试文件夹与dist位于同一级别,我将如何升级?
会是这种事吗?
basePath: '../dist/'
files: [
'app/**/*.mock.js',
'assets/scripts/bower_libs.js',
'assets/scripts/main.js',
'../test/src/**/*.js',
'app/**/*.spec.js'
],
Run Code Online (Sandbox Code Playgroud)
这可能是一个非常愚蠢的问题,但我只是想确定一下!
我正在尝试在新的ASP.NET 5应用程序中为Aurelia设置骨架导航项目.我已经尝试了很多东西,并且相信我已经接近了,但我真的陷入了客户端测试.
我从GitHub上的Aurelia repo 下载了骨架项目并解压缩.
我利用斯科特·艾伦的建议设置JSPM设置放置JSPM包在wwwroot文件夹中陈述这篇文章.
然后我更新了项目结构,如下所示:
sln
|->wwwroot
|->dist
|->jspm_modules
|->src
|->styles
|->test
|->config.js
|->index.html
|->index.js
|->build
|->Controllers
|->doc
|->node_modules
|->aurelia.protractor.js
|->aureliafile.js
|->gulpfile.js
|->karma.conf.js
|->package.json
|->project.json
|->protractor.conf.js
|->Startup.cs
Run Code Online (Sandbox Code Playgroud)
我有两个问题:
1. Aurelia骨架导航启动项目的测试文件夹应该在哪里生效?一方面,wwwroot很有意义,因为这是其他应用程序特定的javascript文件将存在的地方.另一方面,这些文件不应该被提供给客户端,因此将它们放在wwwroot中并没有多大意义.
2.一旦它们位于项目结构中的适当位置,需要更新哪些文件/值才能使测试正常运行?目前我将它们放在wwwroot目录中.我将karma.conf.js文件中的basePath更新为'wwwroot'.当我执行karma start命令虽然它给我一个404错误试图找到'/base/app-bundle.js'.该文件存在于'wwwroot/dist/app-bundle.js',但我无法弄清楚如何配置karma来找到它.
任何帮助将不胜感激.
我无法使karma-ng-html2js-preprocessor适用于外部模板.
包Json文件:
.....
"gulp-karma": "*",
"karma-coverage": "*",
"karma-jasmine": "*",
"karma-ng-html2js-preprocessor": "*",
"karma-phantomjs-launcher": "*",
.....
Run Code Online (Sandbox Code Playgroud)
Karma配置文件:
config.set({
browsers: [
....
],
frameworks: [
'jasmine'
],
plugins: [
'karma-jasmine',
'karma-phantomjs-launcher',
'karma-ng-html2js-preprocessor'
],
preprocessors: {
'app/**/*.html': 'ng-html2js'
},
ngHtml2JsPreprocessor: {
stripPrefix: 'app/'
}
});
Run Code Online (Sandbox Code Playgroud)
文件在Build文件中定义并传递给gulp-karma.以下是已定义的文件:
config = { test: {
configFile: '.../karma.conf.js',
depends: [
.......
],
files: [
"app/**/*.js",
'app/**/*.html'
]
}
}
Run Code Online (Sandbox Code Playgroud)
在我的指令规范中加载模板,如下所示:
beforeEach(module('app'));
beforeEach(module('app/tem/mytemp.html'));
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Error: [$injector:modulerr] Failed to instantiate module app/tem/mytemp.html due to:
Error: [$injector:nomod] Module 'app/tem/mytemp.html' is not available! …Run Code Online (Sandbox Code Playgroud) 目录结构:
来自GulpFile.js的 Gulp代码
gulp.task('test', function (done) {
karma.start({
configFile: _configFile: __dirname + '\\..\\test\\karma.conf.js',
singleRun: true
}, done);
});
Run Code Online (Sandbox Code Playgroud)
所以我的问题转到父目录并访问karma.conf.js.由于某种原因,路径无法解析..\\回到WebApiRole的父目录.有人能指出我正确的方向吗?
gulp-karma ×10
karma-runner ×7
gulp ×5
directory ×2
javascript ×2
node.js ×2
angularjs ×1
asp.net-core ×1
aurelia ×1
ng-html2js ×1
npm ×1