Search code examples
ember.jsqunitkarma-runner

ember.js unit testing and integration testing


I am exploring ember.js application testing. I came across following blog by Toran Billups Integration testing your ember.js app with QUnit and Karma

When we do karma start it runs all the test found in test directory.

How can I run say tests in only one .js file?

thanks


Solution

  • As @bk11425 suggested, simply modify the 'files' section in your karma.conf.js file from this

    module.exports = function(karma) {
        karma.set({
            basePath: 'js',
    
            files: [
              "vendor/jquery/jquery.min.js",
              "vendor/handlebars/handlebars.js",
              "vendor/ember/ember.js",
              "vendor/jquery-mockjax/jquery.mockjax.js",
              "app.js",
              "tests/*.js",
              "templates/*.handlebars"
            ]
    

    To something like this instead

    module.exports = function(karma) {
        karma.set({
            basePath: 'js',
    
            files: [
              "vendor/jquery/jquery.min.js",
              "vendor/handlebars/handlebars.js",
              "vendor/ember/ember.js",
              "vendor/jquery-mockjax/jquery.mockjax.js",
              "app.js",
              "tests/mytestfile.js",
              "templates/*.handlebars"
            ]
    

    Note- if you are doing integration testing please include the integration helper just above this single test file I showed above