[
https://issues.apache.org/jira/browse/AMBARI-5411?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Antonenko Alexander updated AMBARI-5411:
----------------------------------------
Description:
Add [Karma|http://karma-runner.github.io/0.12/index.html] as additional tool
for running FE tests. Karma provides great functionality and powered with a lot
of useful plugins. It can improve testing experience and prevent bugs appearing
before pushing your changes to git repository.
h2. Setup
First of all there are no changes to testing with *mocha-phantomjs* and
additional packages doesn't break any compatibility with dev and build tools.
You need *node.js* >= 0.10. I recommend to install node.js by
[nvm|https://github.com/creationix/nvm](Unix only).
Install required packages. Run after patch applying:
{noformat}$ npm install {noformat}
Now you have installed Karma in *node_modules/* folder. If you want to install
Karma globally run:
{noformat}$ npm i -g [email protected]{noformat}
Run karma from *project_root/ambari-web/* folder:
{noformat}
# for locally installed Karma
$ node_modules/karma/bin/karma start
# for globally installed Karma
$ karma start
{noformat}
This command will run karma server on http://localhost:9876 and repeat tests
while files changing.
PhantomJS is default browser for running, but you can open
http://localhost:9876 in any browser which will run tests also.
To generate coverage summary edit *project_root/ambari-web/karma.conf.js*:
{noformat}
...
preprocessors: {
'!(vendor|node_modules|test)/**/!(karma_setup|tests).js': 'coverage', //
uncomment this line
'app/templates/**/*.hbs': ['ember-precompiler-brunch', 'common-require'],
'app!(assets)/**/!(karma_setup|tests).js': ['common-require'],
'test/**/*.js': ['common-require']
},
....
reporters: ['progress','coverage']
{noformat}
Look to *project_root/ambari-web/public/coverage/*. You can setup custom path
in #coverageReporter config property.
If you have problems with PhantomJS disconnecting, install it from [download
page|http://phantomjs.org/download.html] and set shell variable *PHANTOMJS_BIN*
with path to executable file (by default is */usr/bin/phantomjs*). You can add
this variable to your shell profile file, or make it session only by:
{noformat}$ export PHANTOMJS_BIN=/usr/bin/phantomjs{noformat}
h3. Windows Setup
Tested with node.js v 0.10.20
You need to install, if not installed:
- [Visual
C++|http://www.visualstudio.com/downloads/download-visual-studio-vs#d-2010-express]
- [Python 2.6|https://www.python.org/ftp/python/2.6.6/python-2.6.6.msi]
- [Node.js|http://nodejs.org/download/]
h2. Karma plugin for Intellij Platform IDE
Install plugin from ??File -> Settings -> IDE Settings -> Plugins??.
After IDE restart go to ??Run -> Edit Configuration??.
Add configuration: press *plus* button, select *Karma*. Now fill inputs with
path to: *Node.js interpreter*, *Karma node package* and *Configuration file*
it should be *project_root/ambari-web/karma.conf.js*.
After setup you can run karma from *Debug panel*
[picture-1|https://issues.apache.org/jira/secure/attachment/12639425/karma-snapshot-1.png]
and you will see progress in *4: Run* tab
[picture-2|https://issues.apache.org/jira/secure/attachment/12639426/karma-snapshot-2.jpeg].
You can set *Auto-test* by pressing ??Toggle auto-test?? button.
was:
Add [Karma|http://karma-runner.github.io/0.12/index.html] as additional tool
for running FE tests. Karma provides great functionality and powered with a lot
of useful plugins. It can improve testing experience and prevent bugs appearing
before pushing your changes to git repository.
h2. Setup
First of all there are no changes to testing with *mocha-phantomjs* and
additional packages doesn't break any compatibility with dev and build tools.
You need *node.js* >= 0.10. I recommend to install node.js by
[nvm|https://github.com/creationix/nvm](Unix only).
Install required packages. Run after patch applying:
{noformat}$ npm install {noformat}
Now you have installed Karma in *node_modules/* folder. If you want to install
Karma globally run:
{noformat}$ npm i -g [email protected]{noformat}
Run karma from *project_root/ambari-web/* folder:
{noformat}
# for locally installed Karma
$ node_modules/karma/bin/karma start
# for globally installed Karma
$ karma start
{noformat}
This command will run karma server on http://localhost:9876 and repeat tests
while files changing.
PhantomJS is default browser for running, but you can open
http://localhost:9876 in any browser which will run tests also.
To generate coverage summary edit *project_root/ambari-web/karma.conf.js*:
{noformat}
...
preprocessors: {
'!(vendor|node_modules|test)/**/!(karma_setup|tests).js': 'coverage', //
uncomment this line
'app/templates/**/*.hbs': ['ember-precompiler-brunch', 'common-require'],
'app!(assets)/**/!(karma_setup|tests).js': ['common-require'],
'test/**/*.js': ['common-require']
},
....
reporters: ['progress','coverage']
{noformat}
Look to *project_root/ambari-web/public/coverage/*. You can setup custom path
in #coverageReporter config property.
If you have problems with PhantomJS disconnecting, install it from [download
page|http://phantomjs.org/download.html] and set shell variable *PHANTOMJS_BIN*
with path to executable file (by default is */usr/bin/phantomjs*). You can add
this variable to your shell profile file, or make it session only by:
{noformat}$ export PHANTOMJS_BIN=/usr/bin/phantomjs{noformat}
h3. Windows Setup
Tested with node.js v 0.10.20
You need to install, if not installed:
- [Visual
C++|http://www.visualstudio.com/downloads/download-visual-studio-vs#d-2010-express]
- [Python 2.6|https://www.python.org/ftp/python/2.6.6/python-2.6.6.msi]
- [Node.js|http://nodejs.org/download/]
h2. Karma plugin for Intellij Platform IDE
Install plugin from ??File -> Settings -> IDE Settings -> Plugins??.
After IDE restart go to ??Run -> Edit Configuration??.
Add configuration: press *plus* button, select *Karma*. Now fill inputs with
path to: *Node.js interpreter*, *Karma node package* and *Configuration file*
it should be *project_root/ambari-web/karma.conf.js*.
After setup you can run karma from *Debug panel*
[picture-1|https://issues.apache.org/jira/secure/attachment/12639425/karma-snapshot-1.png]
and you will see progress in *4: Run* tab
[picture-2|https://hortonworks.jira.com/secure/attachment/30974/karma-snapshot-2.jpeg].
You can set *Auto-test* by pressing ??Toggle auto-test?? button.
> Karma integration.
> ------------------
>
> Key: AMBARI-5411
> URL: https://issues.apache.org/jira/browse/AMBARI-5411
> Project: Ambari
> Issue Type: Task
> Components: client
> Affects Versions: 1.6.0
> Reporter: Antonenko Alexander
> Assignee: Antonenko Alexander
> Fix For: 1.6.0
>
> Attachments: karma-snapshot-1.png, karma-snapshot-2.jpeg
>
>
> Add [Karma|http://karma-runner.github.io/0.12/index.html] as additional tool
> for running FE tests. Karma provides great functionality and powered with a
> lot of useful plugins. It can improve testing experience and prevent bugs
> appearing before pushing your changes to git repository.
> h2. Setup
> First of all there are no changes to testing with *mocha-phantomjs* and
> additional packages doesn't break any compatibility with dev and build tools.
>
> You need *node.js* >= 0.10. I recommend to install node.js by
> [nvm|https://github.com/creationix/nvm](Unix only).
> Install required packages. Run after patch applying:
> {noformat}$ npm install {noformat}
> Now you have installed Karma in *node_modules/* folder. If you want to
> install Karma globally run:
> {noformat}$ npm i -g [email protected]{noformat}
> Run karma from *project_root/ambari-web/* folder:
> {noformat}
> # for locally installed Karma
> $ node_modules/karma/bin/karma start
> # for globally installed Karma
> $ karma start
> {noformat}
> This command will run karma server on http://localhost:9876 and repeat tests
> while files changing.
> PhantomJS is default browser for running, but you can open
> http://localhost:9876 in any browser which will run tests also.
> To generate coverage summary edit *project_root/ambari-web/karma.conf.js*:
> {noformat}
> ...
> preprocessors: {
> '!(vendor|node_modules|test)/**/!(karma_setup|tests).js': 'coverage', //
> uncomment this line
> 'app/templates/**/*.hbs': ['ember-precompiler-brunch',
> 'common-require'],
> 'app!(assets)/**/!(karma_setup|tests).js': ['common-require'],
> 'test/**/*.js': ['common-require']
> },
> ....
> reporters: ['progress','coverage']
> {noformat}
> Look to *project_root/ambari-web/public/coverage/*. You can setup custom path
> in #coverageReporter config property.
> If you have problems with PhantomJS disconnecting, install it from [download
> page|http://phantomjs.org/download.html] and set shell variable
> *PHANTOMJS_BIN* with path to executable file (by default is
> */usr/bin/phantomjs*). You can add this variable to your shell profile file,
> or make it session only by: {noformat}$ export
> PHANTOMJS_BIN=/usr/bin/phantomjs{noformat}
> h3. Windows Setup
> Tested with node.js v 0.10.20
> You need to install, if not installed:
> - [Visual
> C++|http://www.visualstudio.com/downloads/download-visual-studio-vs#d-2010-express]
> - [Python 2.6|https://www.python.org/ftp/python/2.6.6/python-2.6.6.msi]
> - [Node.js|http://nodejs.org/download/]
> h2. Karma plugin for Intellij Platform IDE
> Install plugin from ??File -> Settings -> IDE Settings -> Plugins??.
> After IDE restart go to ??Run -> Edit Configuration??.
> Add configuration: press *plus* button, select *Karma*. Now fill inputs with
> path to: *Node.js interpreter*, *Karma node package* and *Configuration file*
> it should be *project_root/ambari-web/karma.conf.js*.
> After setup you can run karma from *Debug panel*
> [picture-1|https://issues.apache.org/jira/secure/attachment/12639425/karma-snapshot-1.png]
> and you will see progress in *4: Run* tab
> [picture-2|https://issues.apache.org/jira/secure/attachment/12639426/karma-snapshot-2.jpeg].
> You can set *Auto-test* by pressing ??Toggle auto-test?? button.
--
This message was sent by Atlassian JIRA
(v6.2#6252)