【问题标题】:Set config's 'browsers' property in the command line in karma runner在 karma runner 的命令行中设置配置的“浏览器”属性
【发布时间】:2013-05-24 15:47:02
【问题描述】:

我通常使用 browsers=['PhantomJS'] 来运行我的 karma 规范,因为它比 chrome 更快,而且当 chrome 在每次启动时在窗口前打开浏览器时我发现有点烦人.

但是当我有错误需要调试时,我将 karma.conf.js 浏览器更改为 ['Chrome']。

我想在启动 karma 时设置此属性,例如:'karma start --browsers=[Chrome]'

这可能吗?

【问题讨论】:

    标签: angularjs karma-runner


    【解决方案1】:

    您只需使用 --browsers 参数,它将覆盖您的配置文件浏览器部分。

    $ karma start config/testacular.conf.js --browsers Chrome
    

    其中 Chrome 是浏览器的名称或二进制文件的路径。

    例如,我只配置了一个小型 Qt 浏览器。如果我使用上面的行,它会运行 Chrome。

    INFO [karma]: Karma server started at http://localhost:9876/
    INFO [launcher]: Starting browser Chrome
    INFO [Chrome 24.0 (Linux)]: Connected on socket id DxbVJNX0jIoe1CbaWf9V
    Chrome 24.0 (Linux): Executed 74 of 74 SUCCESS (0.443 secs / 0.232 secs)
    ...
    

    或者,例如,我家中有 Firefox beta、aurora 和 release。我运行测试版:

    $ karma start config/testacular.conf.js --browsers ~/firefox/firefox
    
    $ karma start --help
    Karma - Spectacular Test Runner for JavaScript.
    
    START - Start the server / do a single run.
    
    Usage:
      karma start [<configFile>] [<options>]
    
    Options:
      --port                <integer> Port where the web server is running.                        
      --runner-port         <integer> Port where the server is listening for runner.               
      --auto-watch          Auto watch source files and run on change.                             
      --no-auto-watch       Do not watch source files.                                             
      --log-level           <disable | error | warn | info | debug> Level of logging.              
      --colors              Use colors when reporting and printing logs.                           
      --no-colors           Do not use colors when reporting or printing logs.                     
      --reporters           List of reporters (available: dots, progress, junit).                  
      --browsers            List of browsers to start (eg. --browsers Chrome,ChromeCanary,Firefox).
      --capture-timeout     <integer> Kill browser if does not capture in given time [ms].         
      --single-run          Run the test when browsers captured and exit.                          
      --no-single-run       Disable single-run.                                                    
      --report-slower-than  <integer> Report tests that are slower than given time [ms].           
      --help                Print usage and options.                                               
      --version             Print current version.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-21
      • 2013-07-05
      • 2014-02-25
      • 2018-10-05
      相关资源
      最近更新 更多