jasmine with jscoverage automated testing

前端 未结 2 889
时光取名叫无心
时光取名叫无心 2021-02-20 15:57

Had been looking at the jsunit and jcoverage demos here (click on coverage report link. Open this in a new tab).

I was wondering if any one had done anything si

相关标签:
2条回答
  • 2021-02-20 16:24

    If you're not using the jasmine-gem, or don't want to have to run a server to check coverage, I've written a gem that pulls together jscoverage and jasmine. It can run as a rake task in your CI builds.

    It can be found here: https://github.com/firstbanco/jasmine-coverage

    Install it, then just run

    bundle exec rake jasmine:coverage
    

    You're done.

    EDIT: As the author of jasmine-coverage, I feel duty bound to to tell you about a better alternative: teaspoon. It requires more setup, but also allows running in the browser so you can use the Chrome debugger.

    0 讨论(0)
  • 2021-02-20 16:30

    If you're working on a ruby project and using jasmine via jasmine-gem, I have a patch that adds jscoverage support[1].

    If you're using bundler, you can use this version of jasmine with the following command in your Gemfile:

      gem 'jasmine',
        :git        => 'git://github.com/hjdivad/jasmine-gem',
        :submodules => true,
        :branch     => 'jscoverage'
    

    Make sure you've downloaded jscoverage and it's in your $PATH.

    You can then add the following to jasmine.yml

    coverage:
      enabled:    true
      encoding:   utf-8
      tmp_dir:    tmp
      report_dir: public/coverage
      skip_paths:
        - public/javascripts/vendor
    

    If this works for you, you may want to speak up on the pull request[2] to get it, or some variation, into jasmine-gem proper.

    • [1] https://github.com/hjdivad/jasmine-gem/tree/jscoverage
    • [2] https://github.com/pivotal/jasmine-gem/pull/37
    0 讨论(0)
提交回复
热议问题