Karma - 基本路径无法正常工作

时间:2016-02-18 08:40:39

标签: angularjs unit-testing ionic-framework karma-jasmine

这是我第一次尝试使用业力,尝试启动测试时遇到了一些问题。

我的文件夹结构如下:

node_modules
 -angular-mocks
src
 -compiled
 -lib
 -tests
   -karma.conf.js

现在,在我的karma.conf.js中,这是我的文件列表和basepath:

module.exports = function (config) {
    config.set({

        basePath: '../../',

        frameworks: ['jasmine'],

        files: [
            {pattern: 'lib/ionic/js/ionic.bundle.js', included: true, nocache: true, watched: true},
            {pattern: 'node_modules/angular-mocks/angular-mocks.js', included: true, nocache: true, watched: true},
            'compiled/js/*.js',
            'compiled/css/*.css',
            {pattern: 'tests/unit/unit.js', included: true, nocache: true, watched: true}
    ],

    exclude: [],

我在另一个窗口打开命令提示符并使用karma start运行karma,并且所有浏览器都打开并且它们已连接,而不是如果我键入karma run(当karma start仍在运行时),结果如下:

18 02 2016 08:35:26.708:WARN [watcher]: Pattern "c:/src/app/src/tests/src/lib/ionic/js/ionic.bundle.js" does not match any file.
18 02 2016 08:35:26.708:WARN [watcher]: Pattern "c:/src/app/src/tests/src/angular-mocks/angula-mocks.js" does not match any file.
18 02 2016 08:35:26.708:WARN [watcher]: Pattern "c:/src/app/src/tests/src/compiled/js/*.js" does not match any file.
18 02 2016 08:35:26.708:WARN [watcher]: Pattern "c:/src/app/src/tests/src/compiled/css/*.css" does not match any file.
18 02 2016 08:35:26.708:WARN [watcher]: Pattern "c:/src/app/src/tests/src/tests/unit/unit.js" does not match any file.

我可以看到文件路径错误,但我不明白为什么......有什么帮助?

非常感谢

1 个答案:

答案 0 :(得分:0)

对于未来的读者:使用basePath: process.cwd()