【问题标题】:testing angular app using karma and jasmine having error:使用业力和茉莉花测试角度应用程序有错误:
【发布时间】:2015-07-22 20:24:15
【问题描述】:

我是 angular.js 的新手。我正在尝试为我的应用程序运行 Karma 单元测试,但发现了很多问题,因为它期望我安装所有必需的依赖项,如 node.js、npm、karma 等。

现在当我进入我的项目目录并运行这个命令 karma start karma 我有这个错误:

C:\wamp\www\First-angular-App>karma start karma.conf
ERROR [config]: Invalid config file!
SyntaxError: Unexpected string

karma.conf

module.exports = function(config) {
  config.set({ 
    basePath: '', 
    frameworks: ['jasmine'], 
    exclude: [ ], 
    files: [ 'First-angular-App/source/index.html', 'First-angular-App/source/myApp.js' 'First-angular-App/source/myAppCtrl.js' ] 
    preprocessor 
    preprocessors: { }, 
    reporters: ['progress'], 
    port: 9876, 
    colors: true, 
    config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 
    logLevel: config.LOG_INFO, 
    changes 
    autoWatch: false, 
    launcher browsers: ['Chrome'], 
    singleRun: true 
  });
};

为什么它给我错误无效的配置文件?

【问题讨论】:

  • 您运行“业力启动”并收到错误“无效的配置文件”。不知道你不明白什么,但错误说“我亲爱的印度朋友!你的配置设置有问题!请检查你那里的所有东西都存在,有正确的路径到你的 npm 库和更多的原因...”上传你的 karma.conf.js,我不是邪神来给你建议的。
  • @Dmitri 如果不明白我的问题,为什么写故事无济于事,你的工作没问题
  • @NumanHassan @Dimitri 理解您的问题没有问题。收到ERROR [config]: Invalid config file!时请上传config file
  • @KrzysztofSafjanowski 这是我的 karma.conf module.exports = function(config) { config.set({ basePath: '', frameworks: ['jasmine'], exclude: [ ], files: [ 'First-angular-App/source/index.html', 'First-angular-App/source/myApp.js' 'First-angular-App/source/myAppCtrl.js' ] 预处理器 预处理器:{},记者: ['progress'],端口:9876,颜色:true,config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG logLevel:config.LOG_INFO,更改 autoWatch:false,启动器浏览器:['Chrome'],singleRun:true }); };
  • @KrzysztofSafjanowski 我按照你的建议做了,但我仍然收到同样的错误

标签: jasmine karma-runner


【解决方案1】:

可能应该看起来像 - 请查看添加到配置中的两个 cmets。

 module.exports = function(config) {
    config.set({
        basePath: '',
        frameworks: ['jasmine'],
        exclude: [ ],
        files: [ 'First-angular-App/source/index.html', 'First-angular-App/source/myApp.js', 'First-angular-App/source/myAppCtrl.js' ],
        // preprocessor - mark this as comment
        preprocessors: { },
        reporters: ['progress'],
        port: 9876,
        colors: true,
        // config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - one more comment
        logLevel: config.LOG_INFO,
        // changes - mark this as comment
        autoWatch: false,
        // launcher 
        browsers: ['Chrome'],
        singleRun: true
    });
};

【讨论】:

  • 我做了你上面提到的但我仍然收到同样的错误
  • 它仍然给出一些关于文件路径的错误,尽管业力正在运行,但文件不匹配任何文件
  • @NumanHassan 你不知道文件名和存储位置吗?你有没有试过阅读像karma-runner.github.io/0.13/intro/configuration.html这样的文档?
猜你喜欢
  • 2015-12-26
  • 1970-01-01
  • 2023-04-06
  • 2017-01-15
  • 1970-01-01
  • 2017-05-02
  • 2017-08-19
  • 2014-12-12
  • 2017-10-23
相关资源
最近更新 更多