r3b / grunt-protractor-coverage

Coverage analysis for Protractor tests
Apache License 2.0
38 stars 29 forks source link

Instrumented 0 files (skipped 1 file) #35

Closed shaoping closed 9 years ago

shaoping commented 9 years ago

i want to know what js can be Instrumented, my js contain the jquery v1.11.1 ,AngularJS v1.2.24 , and my own code , but it skipped , why?

then i tested the simple js file , it also skipped ,eg:

function test(){
     alert(11);
}

the config file is :

if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function(grunt) {

  grunt.registerTask('test', ['clean:coverage','copy:instrument','instrument','protractor_coverage:chrome', 'makeReport']);

  grunt.initConfig({
    copy: {
        instrument: {
            files: [{
                src: ['uee.cars/**/pc/**/app.js'],
                dest: 'coverage/'
            }]
        },
    },

    clean: {
        coverage: ['coverage', 'instrumented', 'reports']
    },

    connect:{
      server:{
        options:{
          port: 8080,
          base: 'coverage'
        }
      },
    },

    instrument:{
      files: 'uee.cars/**/pc/**/app.js',
      options: {
        lazy: true,
        basePath: "coverage"
      }
    },

    protractor_coverage:{
        options: {
            configFile: 'chrome.conf.js',
            keepAlive: true,
            noColor: false,
            coverageDir: 'coverage',
            args: {}
        },
        chrome: {
            options: {
                args: {
                    baseUrl: 'http://localhost:8080/',
                    // Arguments passed to the command
                    'browser': 'chrome'
                }
            }
        },
    },

    makeReport: {
        src: 'coverage/*.json',
        options: {
            type: 'lcov',
            dir: 'coverage',
            print: 'detail'
        }
    }
});

  grunt.loadNpmTasks('grunt-protractor-coverage');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-istanbul');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-coveralls');
};
shaoping commented 9 years ago

i changed the instrument:option lazy to false ,then above error has solved. but when i execute the makeReport , the error occurd with:

Running "makeReport" task
Fatal error: Cannot set property 'covered' of undefined

so what is the reason of this?

shaoping commented 9 years ago

ok, i really know what the reson of (Fatal error: Cannot set property 'covered' of undefined) , the sourece file and the instrumented file should be both exist .