设置配置的浏览器'在karma runner的命令行中的属性

时间:2013-05-24 03:08:31

标签: angularjs karma-runner

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

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

我想在开始业力时设置此属性,例如:'karma start --browsers = [Chrome]'

这是可能的吗?

1 个答案:

答案 0 :(得分:22)

你只需要使用--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)
...

或者,例如,我有火狐beta,极光和我家中的释放。我用:

运行测试版
$ 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.