Uploaded image for project: 'Ambari'
  1. Ambari
  2. AMBARI-5411

Karma integration.

Log workAgile BoardRank to TopRank to BottomAttach filesAttach ScreenshotBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersCreate sub-taskConvert to sub-taskLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.6.0
    • 1.6.0
    • ambari-web
    • None

    Description

      Add Karma 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.

      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(Unix only).
      Install required packages. Run after patch applying:

      $ npm install 

      Now you have installed Karma in node_modules/ folder. If you want to install Karma globally run:

      $ npm i -g karma@0.11.14

      Run karma from project_root/ambari-web/ folder:

      # for locally installed Karma
      $ node_modules/karma/bin/karma start
      
      # for globally installed Karma
      $ karma start
      

      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:

      ...
      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']
      

      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 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:

      $ export PHANTOMJS_BIN=/usr/bin/phantomjs

      Windows Setup

      Tested with node.js v 0.10.20
      You need to install, if not installed:

      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 and you will see progress in 4: Run tab picture-2. You can set Auto-test by pressing Toggle auto-test button.

      Attachments

        1. AMBARI-5411.patch
          8 kB
          Antonenko Alexander
        2. karma-snapshot-1.png
          13 kB
          Antonenko Alexander
        3. karma-snapshot-2.jpeg
          74 kB
          Antonenko Alexander

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            aantonenko Antonenko Alexander Assign to me
            aantonenko Antonenko Alexander
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment