• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

craigburke/karma-gradle: Gradle Plugin for Running tests with Karma

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

craigburke/karma-gradle

开源软件地址(OpenSource Url):

https://github.com/craigburke/karma-gradle

开源编程语言(OpenSource Language):

Groovy 100.0%

开源软件介绍(OpenSource Introduction):

Karma Gradle Plugin

This Gradle plugin allows you to run Jasmine, Qunit, or Mocha tests using the Karma test runner.

Getting Started

plugins {
    id 'com.craigburke.karma' version '1.4.4'
}

Tasks

The plugin adds the following tasks to your build:

Task

Description

karmaRun

Runs your tests

karmaWatch

Runs your tests in watch mode

karmaRefresh

Refresh the generated karma config file

karmaClean

Deletes the karma config file and removes the dependencies

Configuration

Properties

You can use the same properties you’d set in your karma.config.js file directly in build.gradle

plugins {
    id 'com.craigburke.karma' version '1.4.4'
}

karma {
    basePath = 'src/assets' // <1>
    colors = true // <2>
    profile 'angularJS' // <3>

    browsers = ['PhantomJS'] // <4>
    frameworks = ['jasmine'] // <5>
    reporters = ['junit'] // <6>
}
  1. Optional base path for resolving relative paths

  2. Whether to show colors on the screen (default is true)

  3. File pattern profile to use. Possible values: default, angularJS

  4. Runs tests in the browsers listed here and installs the launcher dependencies. Possible values: PhantomJS, Firefox, Chrome, ChromeCanary, Opera, Internet Explorer, Safari

  5. Uses the listed frameworks and installs their dependencies. Possible values: jasmine, mocha, qunit.

  6. Uses additional reporters and installs their dependencies. Possible values: progress, junit, coverage, growl, teamcity

Note
if basePath is not set, it defaults the project root.

Profiles

Profiles allow you to use commonly used file patterns and sensible defaults for the files list. Currently there is a default and an angularJS profile.

plugins {
    id 'com.craigburke.karma' version '1.4.4'
}

karma {
    profile 'angularJS'  // <1>
}
  1. Applying the angularJS profile

For any profile, the files to be loaded are broken into three groups (libraries, source and tests). You can override the base path and file pattern list for any of these groups within a profile. This can be useful if the order that the files are loaded in matters.

karma {
    profile('default')  {
        libraryBases = ['**/libs/']
        libraryFiles = ['jquery.js', 'lib1.js'] // <1>

        sourceBases = ['src/', 'app/']
        sourceFiles = ['source1.js', '**/*.js'] // <2>

        testBases = ['tests/']
        testFiles = ['**/*test.js'] // <3>
    }
}
  1. Overriding both the base path and list of library files. This will add /libs/**/jquery.js and /libs/**/lib1.js to the start of the karma files list

  2. Overriding both the base path and list of source files. This will add src/source1.js, app/source1.js, src/**/*.js and app/**/*.js to the files list after the library files.

  3. Overriding both the base path and list of test files. This will add /tests/**/*test.js to the files list after the source files.

Note
you can always build your own files list by setting the files property directly (see Advanced Configuration).

Dependencies

By default the plugin will automatically install all needed browser, framework and reporter dependencies. If you need to add an additional npm dependency you can set it using the dependencies method.

karma {
    dependencies(['karma-sinon'])
}

You can also lock any dependency to a specific version by adding it this way with @ version syntax:

karma {
    dependencies(['[email protected]'])
}

Advanced Configuration

In addition to the properties listed above, you can also include set other Karma properties through the DSL.

karma {
    files = [
        'bower/angular/angular.js',
        '**/!(*.spec).js',
        '**/*.spec.js'
    ]

    exclude = ['jquery.js']
    junitReporter = [outputDir: 'test-dir' ]
}



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap