Skip to content

Missing coverage object- "No coverage object in the browser." #53

Open
@garimamathur16

Description

@garimamathur16

Hi,

While working on code coverage for protractor e2e cases, using grunt-protractor-coverage, I observed this issue on test execution.

PFB the gruntfile.js

module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Before generating any new files, remove any previously-created files.
clean: {
tests: ['coverage', 'coverage_reports'],
},
copy: {
coverageE2E: {
files: [{
expand: true,
dot: true,
cwd: '/path/to/base/directory/',
dest: 'coverage/e2e/instrumented/app',
src: [
'WebContent/resources/css/',
'WebContent/resources/fonts/
',
'WebContent/resources/html/',
'WebContent/resources/images/
',
]
}]
}

    },
    instrument: {
                files: ['../WebContent/resources/js/**/*.js'],
                options: {
                    lazy: true,
                    coverageVariable: '__coverage__',
                    basePath: 'coverage/e2e/instrumented/test/'
                }
    },
    connect: {
      server: {
        options: {
          port: 3000,
          hostname: 'localhost',
        }
      },
    },
    protractor_coverage: {
        options: {
            configFile: "node_modules/protractor/example/conf.js", // Default config file 
            keepAlive: true, // If false, the grunt process stops when the test fails. 
            noColor: false, // If true, protractor will not use colors in its output. 
            //coverageDir: 'coverage/e2e/instrumented/',
            //debug: true,
            args: {
                // Arguments passed to the command 
            }
        },
        custom: {  
            options: {
                configFile: "src/conf.js", // Target-specific config file 
                 //coverageDir: 'coverage',
                 //debug: true,
                args: {
                     baseUrl: 'http://localhost:3000/',
                     // Arguments passed to the command
                    //'browser': 'firefox'
                    },

                run: {}
            }
        }
    },
    makeReport: {
      src: 'coverage/**/*.json',
      options: {
        type: 'html',
        dir: 'coverage_reports',
        print: 'detail'
      }
    }




});

//loading grunt task
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.loadNpmTasks('grunt-protractor-webdriver');
grunt.loadNpmTasks('grunt-protractor-coverage');
grunt.loadNpmTasks('grunt-istanbul');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-connect');


//Registering task to be executed

grunt.registerTask('test', ['clean:tests','copy:coverageE2E', 'instrument' ,'connect','protractor_coverage:custom','makeReport']);

};

I suppose while providing the instrumented code to the test case at http://localhost:3000 , there appears to be some problem, as this is acting like base url, to which I have appended application relative paths when doing a browser.get('/testgui'). however, this throws the error-Angular could not be found on the page.

Is there anything I have misunderstood or missed?

Any suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions