Karma 无法匹配任何 js 文件
Posted
技术标签:
【中文标题】Karma 无法匹配任何 js 文件【英文标题】:Karma can't match any js file 【发布时间】:2016-03-22 13:37:23 【问题描述】:我开了
karma start karma.conf.js --log-level debug --single-run
然后得到
16 12 2015 14:53:16.764:WARN [plugin]:加载“C:\Users\denis.ev\AppData\Roaming\npm\node_modules/karma-phantomjs-launcher”插件时出错: 找不到模块“phantomjs”
16 12 2015 14:53:17.245:WARN [reporter]: 无法加载“junit”,它没有注册! 也许您缺少一些插件?
16 12 2015 14:53:17.510:WARN [watcher]: 模式“C:/Users/denis.ev/Documents/Bleu[hottask]/Bleu.Web/src/assets/libs/jquery-2.1.4 .js" 不匹配任何文件。
16 12 2015 14:53:17.578:WARN [watcher]: Pattern "C:/Users/denis.ev/Documents/Bleu[hottask]/Bleu.Web/src/assets/libs/moment.js" 确实不匹配任何文件。
16 12 2015 14:53:17.603:WARN [watcher]: Pattern "C:/Users/denis.ev/Documents/Bleu[hottask]/Bleu.Web/src/assets/libs/bootstrap.js" 确实不匹配任何文件。
16 12 2015 14:53:17.711:WARN [watcher]: Pattern "C:/Users/denis.ev/Documents/Bleu[hottask]/Bleu.Web/src/assets/libs/angular.js" 确实不匹配任何文件。
16 12 2015 14:53:19.426:WARN [watcher]: 模式“C:/Users/denis.ev/Documents/Bleu[hottask]/Bleu.Web/src/assets/libs/angular/angularjs-nvd3 -directives.js" 不匹配任何文件。
16 12 2015 14:53:19.690:INFO [karma]:Karma v0.13.15 服务器开始于 http://localhost:9876/
16 12 2015 14:53:19.920:WARN [launcher]:无法加载“PhantomJS”,它没有注册!
karma.conf.js
// Karma configuration
// Generated on Tue Jul 22 2014 13:41:07 GMT+0400 (Russian Standard Time)
module.exports = function (config)
config.set(
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '../',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
/*
* "~/src/assets/libs/jquery-version.js",
"~/src/assets/libs/moment.js",
"~/src/assets/libs/bootstrap.js",
"~/src/assets/libs/angular.js",
"~/src/assets/libs/angular/angular-ui-router.js",
"~/src/assets/libs/angular/ui-bootstrap-tpls.js",
"~/src/assets/libs/angular/ui-grid.js",
"~/src/assets/libs/angular/angular-moment.js",
"~/src/assets/libs/angular/datetime-picker.js",
"~/src/assets/libs/angular/angular-local-storage.js",
"~/src/assets/libs/angular/ng-tags-input.modified.js",
"~/src/assets/libs/angular/ng-file-upload.js"
*/
files: [
pattern: 'Bleu.Web/src/assets/libs/jquery-2.1.4.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/moment.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/bootstrap.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/angular.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/angular/angular-ui-router.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/angular/ui-bootstrap-tpls.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/angular/ui-grid.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/angular/angular-moment.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/angular/datetime-picker.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/angular/angular-local-storage.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/angular/ng-tags-input.modified.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/angular/ng-file-upload.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/angular/ng-sortable.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/angular/angular-ui-tree.js', included: true ,
pattern: 'Bleu.Web/src/app/*/*.js', included: true ,
pattern: 'Bleu.Web/src/core/*/*.js', included: true ,
pattern: 'Bleu.Web/src/**/services/*.js', included: true ,
pattern: 'Bleu.Web/src/**/models/*.js', included: true ,
pattern: 'Bleu.Web/src/**/mappers/*.js', included: true ,
pattern: 'Bleu.Web/src/**/constants/*.js', included: true ,
pattern: 'Bleu.Web/src/**/enums/*.js', included: true ,
pattern: 'Bleu.Web/src/**/helpers/*.js', included: true ,
pattern: 'Bleu.Web/src/core/main/transports/FakeTransport.js', included: true ,
pattern: 'Bleu.Web.Tests.Client/mocks/*/*.js', included: true ,
pattern: 'Bleu.Web.Tests.Client/mocks/**/*.js', included: true ,
pattern: 'Bleu.Web.Tests.Client/testData/**/*.js', included: true ,
pattern: 'Bleu.Web.Tests.Client/Specs/**/*.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/d3.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/nv.d3.js', included: true ,
pattern: 'Bleu.Web/src/assets/libs/angular/angularjs-nvd3-directives.js', included: true
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors:
,
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
//reporters: ['progress'],
//reporters: ['html'],
reporters: ['dots', 'junit'],
junitReporter:
outputFile: 'test-results.xml'
,
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
//logLevel: config.LOG_DEBUG,
logLevel: config.LOG_ERROR,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
//browsers: ['Chrome', 'PhantomJS', 'Firefox'],
browsers: ['PhantomJS'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true
);
;
我需要什么来启动我的测试? 谢谢
【问题讨论】:
显示karma.conf.js
文件
添加了karma.conf.js
,Tomasz
你的项目在哪里? C:/Users/denis.ev/Documents/Bleu[hottask]/Bleu.Web/project/
?显示您的目录结构。尤其是karma.conf.js
和src
目录在哪里。
我将 Bleu.Web 替换为项目 这是我的路径:C:\Users\denis.ev\Documents\BleuTest\Bleu.Web.Tests.Client\
换回来不误导你
【参考方案1】:
WARN [reporter]:无法加载“junit”,它没有注册!也许您缺少一些插件?
您没有 juint-reporter 插件。通过npm install karma-junit-reporter --save-dev
安装它
WARN [插件]:加载“C:\Users\denis.ev\AppData\Roaming\npm\node_modules/karma-phantomjs-launcher”插件时出错:找不到模块“phantomjs”
您没有 phantomjs。通过npm install -g phantomjs
安装它
WARN [watcher]:模式“C:/Users/denis.ev/Documents/Bleu[hottask]/Bleu.Web/src/assets/libs/jquery-2.1.4.js”不匹配任何文件。
files 的 basePath 或 pattern 可能配置错误。尝试将 basePath 设置为 .
。
【讨论】:
最终成为我的基本路径问题。默认是''
,但我需要../..
。没有对WARNING Pattern ... does not match any file
中的路径给予足够的关注,没有意识到它确实不是一个有效的路径,因为默认的基本路径以上是关于Karma 无法匹配任何 js 文件的主要内容,如果未能解决你的问题,请参考以下文章
茉莉花匹配器功能未在 angularjs/karma 单元测试中加载
Karma + Jasmine + Durandal + KnockoutJS + RequireJS 单元测试中不匹配的匿名 define() 模块
错误:无法匹配任何路由。 URL 段:“配置文件”或加载资源失败:服务器响应状态为 401(未授权)
由于 MIME 类型不匹配,无法加载 JavaScript 文件
无法将 iPad 应用程序转换为 Mac 应用程序:Xcode 找不到任何与“maccatalyst.com...”匹配的 Mac Catalyst 应用程序开发配置文件