我试图在Windows 7中运行带有phantomJS的karmatest运行器。这是配置文件:
// Karma configuration
// http://karma-runner.github.io/0.12/config/configuration-file.html
// Generated on 2015-06-01 using
// generator-karma 0.8.3
module.exports = function (config) {
'use strict';
config.set({
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
//preprocessors: {
// 'app/**/*.js': ['coverage']
//},
//
preprocessors: {
'**/*.html': ['ng-html2js'],
'app/**/*.js': ['coverage']
},
reporters: ['progress', 'coverage'],
// base path, that will be used to resolve files and exclude
basePath: '../',
// testing framework to use (jasmine/mocha/qunit/...)
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.4/angular.js',
'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.4/angular-mocks.js',
'bower_components/angular-animate/angular-animate.js',
'bower_components/angular-ui-router/release/angular-ui-router.js',
'bower_components/angular-bootstrap/ui-bootstrap.js',
'bower_components/angular-smart-table/dist/smart-table.min.js',
'bower_components/underscore/underscore.js',
'app/modules/**/*.js',
'app/modules/app.js',
'app/modules/config.js',
//'../app/scripts_old/**/*.js',
// 'test/mock/**/*.js',
'test/spec/**/*.spec.js'
],
// list of files / patterns to exclude
exclude: [],
// web server port
port: 8080,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: [
'PhantomJS'
],
// Which plugins to enable
plugins: [
'karma-phantomjs-launcher',
'karma-jasmine',
'karma-coverage',
'karma-chrome-launcher'
],
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false,
colors: true,
// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_DISABLE
// Uncomment the following lines if you are using grunt's server to run the tests
// proxies: {
// '/': 'http://localhost:9000/'
// },
// URL root prevent conflicts with the site root
// urlRoot: '_karma_'
});
};
我在这里安装了karmaphantomjs启动器: https://www.npmjs.com/package/karma-phantomjs-launcher
我还将phantomjs_bin环境变量设置为\ phantomjs.exe
当我使用chromebrowser时它工作正常。我怎样才能让它运行phantomJS?
答案 0 :(得分:0)
使用以下过程:
cmd
环境变量通过where phantomjs
shell找到phantomjs的路径,然后运行:
PATH
通过运行path
将位置复制到$http.post(apiDomain + '/api/v1/user/logout/', {}, config)
环境变量,然后将其附加到列表中
因为您可以使用env覆盖phantomjs_bin路径,这意味着如果您这样做,它将尝试通过phantomjs.exe运行phantomjs脚本,而不是node.exe。这是可以修复的,但导致了更多的代码路径,我更倾向于回到更简单的解决方案。
<强>参考强>